Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #4796 > unrolled thread

Customize operator new / delete

Started byNephi Immortal <immortalnephi@gmail.com>
First post2011-05-07 19:11 -0700
Last post2011-05-10 13:29 -0700
Articles 3 on this page of 23 — 8 participants

Back to article view | Back to comp.lang.c++


Contents

  Customize operator new / delete Nephi Immortal <immortalnephi@gmail.com> - 2011-05-07 19:11 -0700
    Re: Customize operator new / delete Ian Collins <ian-news@hotmail.com> - 2011-05-08 15:05 +1200
    Re: Customize operator new / delete James Kanze <james.kanze@gmail.com> - 2011-05-08 07:38 -0700
      Re: Customize operator new / delete "io_x" <a@b.c.invalid> - 2011-05-08 19:05 +0200
        Re: Customize operator new / delete Nephi Immortal <immortalnephi@gmail.com> - 2011-05-08 15:35 -0700
          Re: Customize operator new / delete Ian Collins <ian-news@hotmail.com> - 2011-05-09 10:45 +1200
        Re: Customize operator new / delete James Kanze <james.kanze@gmail.com> - 2011-05-10 13:25 -0700
          Re: Customize operator new / delete "io_x" <a@b.c.invalid> - 2011-05-11 09:31 +0200
            Re: Customize operator new / delete "io_x" <a@b.c.invalid> - 2011-05-11 09:56 +0200
              Re: Customize operator new / delete James Kanze <james.kanze@gmail.com> - 2011-05-15 06:14 -0700
                Re: Customize operator new / delete Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-15 23:54 -0700
                  Re: Customize operator new / delete Ian Collins <ian-news@hotmail.com> - 2011-05-16 19:43 +1200
                  Re: Customize operator new / delete Nobody <nobody@nowhere.com> - 2011-05-16 12:53 +0100
                Re: Customize operator new / delete "io_x" <a@b.c.invalid> - 2011-05-18 17:32 +0200
                  Re: Customize operator new / delete Pete Becker <pete@versatilecoding.com> - 2011-05-18 12:38 -0400
            Re: Customize operator new / delete James Kanze <james.kanze@gmail.com> - 2011-05-15 06:12 -0700
    Re: Customize operator new / delete "io_x" <a@b.c.invalid> - 2011-05-08 18:44 +0200
      Re: Customize operator new / delete Nephi Immortal <immortalnephi@gmail.com> - 2011-05-08 15:43 -0700
        Re: Customize operator new / delete "io_x" <a@b.c.invalid> - 2011-05-09 08:47 +0200
          Re: Customize operator new / delete Leigh Johnston <leigh@i42.co.uk> - 2011-05-09 12:58 +0100
            Re: Customize operator new / delete "io_x" <a@b.c.invalid> - 2011-05-10 08:15 +0200
              Re: Customize operator new / delete Leigh Johnston <leigh@i42.co.uk> - 2011-05-10 12:39 +0100
          Re: Customize operator new / delete James Kanze <james.kanze@gmail.com> - 2011-05-10 13:29 -0700

Page 2 of 2 — ← Prev page 1 [2]


#4849

From"io_x" <a@b.c.invalid>
Date2011-05-10 08:15 +0200
Message-ID<4dc8d7ab$0$38652$4fafbaef@reader1.news.tin.it>
In reply to#4831
"Leigh Johnston" <leigh@i42.co.uk> ha scritto nel messaggio

> Typically there will be different code at the call site rather than in the 
> delete functions themselves for example the extra new[] bookkeeping 
> information added after the new[] allocation will be used to call the correct 
> number of destructors before deallocation.

so "delete []" and "delete" to a pointer are the same

[toc] | [prev] | [next] | [standalone]


#4863

FromLeigh Johnston <leigh@i42.co.uk>
Date2011-05-10 12:39 +0100
Message-ID<cuWdnXvNmvF3vlTQnZ2dnUVZ8lCdnZ2d@giganews.com>
In reply to#4849
On 10/05/2011 07:15, io_x wrote:
> "Leigh Johnston"<leigh@i42.co.uk>  ha scritto nel messaggio
>
>> Typically there will be different code at the call site rather than in the
>> delete functions themselves for example the extra new[] bookkeeping
>> information added after the new[] allocation will be used to call the correct
>> number of destructors before deallocation.
>
> so "delete []" and "delete" to a pointer are the same

No they are not the same as they are treated differently by the compiler 
when deleting an array of objects with destructors; i.e. the compiler 
will emit different assembly instructions at the call site of delete[] 
than at the call site of delete (similarly for new[] and new).

/Leigh

[toc] | [prev] | [next] | [standalone]


#4875

FromJames Kanze <james.kanze@gmail.com>
Date2011-05-10 13:29 -0700
Message-ID<9326eef5-c7fc-491d-bd30-6318ac5c539c@f9g2000vbz.googlegroups.com>
In reply to#4826
On May 9, 7:47 am, "io_x" <a...@b.c.invalid> wrote:
> "Nephi Immortal" <immortalne...@gmail.com> ha scritto nel messaggionews:7dbad185-521d-449c-b491-b60af6964602@n10g2000yqf.googlegroups.com...

    [...]
> but i don't understand well too why use 2 delete function
> if they do the same:

Because they aren't required to do the same.  If the two
operator new do something different, then the two operator
delete must also.  Typically, of course, operator new[] will
just call operator new, and operator delete[] will just call
operator delete.  The standard also guarantees this for the
library implementations, so if you just overload operators new
and delete, you should catch all of the memory allocations.

--
James Kanze

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.c++


csiph-web