Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > new algorithm

Reply
Thread Tools

new algorithm

 
 
wijhierbeneden
Guest
Posts: n/a
 
      10-28-2004
Hello

Where can I find some info about the inner working of new/delete??
Is this compiler specific or defined by the standard?? There is a lot
of info about the different malloc implementations but I can't find
anything about new.

thx
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      10-28-2004
wijhierbeneden wrote:
> Where can I find some info about the inner working of new/delete??
> Is this compiler specific or defined by the standard?? There is a lot
> of info about the different malloc implementations but I can't find
> anything about new.


What do you want to know? What C++ book do you have?
 
Reply With Quote
 
 
 
 
Ron Natalie
Guest
Posts: n/a
 
      10-28-2004
wijhierbeneden wrote:
> Hello
>
> Where can I find some info about the inner working of new/delete??
> Is this compiler specific or defined by the standard??


The general behavior is defined by the standard in 3.7.3 that talks
about the allocation functions (operator new/delete) themselves,
5.3.4 and 5.3.5 which talk about the new/delete expressions themselves,
and of course 8.5 and 12.1 which talk about how initialization/consturctor
invocation occurs.

> There is a lot
> of info about the different malloc implementations but I can't find
> anything about new.


The standard doesn't discuss the actual implentation of the allocation
deallocation function internals (just their interfaces) other than to
point out that they are designed to be able to be impelemented on top of
malloc/delete without much toil. In actuality, most implementations
do exactly that. Since they need to coexist with malloc, you have to
pretty much implement one in terms of the other or have them both call
a third common allocator.
 
Reply With Quote
 
David Lindauer
Guest
Posts: n/a
 
      10-29-2004


wijhierbeneden wrote:

> Hello
>
> Where can I find some info about the inner working of new/delete??
> Is this compiler specific or defined by the standard?? There is a lot
> of info about the different malloc implementations but I can't find
> anything about new.
>
> thx


the end results are defined by the standard, but the compiler has a
certain amount of leeway in implementation. Basically what you are
looking for new() is the equivalent of a call to malloc() (assuming you
are using the allocating new rather than the placement new) followed by
an invocation of an appropriate constructor if the object being allocated
has one. If the allocation fails, the user define new handler may be
called, and if that fails an exception may be thrown. If allocating an
array, a constructor is called for each element of the array as
appropriate. For delete, a destructor is called for the object (or each
object in the array) and then the space is freed.

David



 
Reply With Quote
 
wijhierbeneden
Guest
Posts: n/a
 
      10-29-2004
Ron Natalie <(E-Mail Removed)> wrote in message news:<41815851$0$28303$(E-Mail Removed) om>...
> wijhierbeneden wrote:
> > Hello
> >
> > Where can I find some info about the inner working of new/delete??
> > Is this compiler specific or defined by the standard??

>
> The general behavior is defined by the standard in 3.7.3 that talks
> about the allocation functions (operator new/delete) themselves,
> 5.3.4 and 5.3.5 which talk about the new/delete expressions themselves,
> and of course 8.5 and 12.1 which talk about how initialization/consturctor
> invocation occurs.
>
> > There is a lot
> > of info about the different malloc implementations but I can't find
> > anything about new.

>
> The standard doesn't discuss the actual implentation of the allocation
> deallocation function internals (just their interfaces) other than to
> point out that they are designed to be able to be impelemented on top of
> malloc/delete without much toil. In actuality, most implementations
> do exactly that. Since they need to coexist with malloc, you have to
> pretty much implement one in terms of the other or have them both call
> a third common allocator.



Is there no info about the exact inner implementations available??
That is what i want, i want to know how the Virtual table is created
how the object is build on the heap, ...
That's why i need the inner working of new
There must be some info about that, no??
 
Reply With Quote
 
Gianni Mariani
Guest
Posts: n/a
 
      10-29-2004
wijhierbeneden wrote:
> Ron Natalie <(E-Mail Removed)> wrote in message news:<41815851$0$28303$(E-Mail Removed) om>...

....
>
> Is there no info about the exact inner implementations available??
> That is what i want, i want to know how the Virtual table is created
> how the object is build on the heap, ...
> That's why i need the inner working of new
> There must be some info about that, no??


the new operator is associated with dynamically created objects only.

The compiler is responsible for dealing with how virtual functions and
auto objects are allocated. This almost certainly has nothing to do
with new.
 
Reply With Quote
 
Stuart Gerchick
Guest
Posts: n/a
 
      10-29-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (wijhierbeneden) wrote in message news:<(E-Mail Removed) om>...
> Hello
>
> Where can I find some info about the inner working of new/delete??
> Is this compiler specific or defined by the standard?? There is a lot
> of info about the different malloc implementations but I can't find
> anything about new.
>
> thx


A good book for the inner workings of C++ is "Inside the C++ Object
Model" by Stanley Lippman
 
Reply With Quote
 
wijhierbeneden
Guest
Posts: n/a
 
      10-29-2004
Gianni Mariani <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> wijhierbeneden wrote:
> > Ron Natalie <(E-Mail Removed)> wrote in message news:<41815851$0$28303$(E-Mail Removed) om>...

> ...
> >
> > Is there no info about the exact inner implementations available??
> > That is what i want, i want to know how the Virtual table is created
> > how the object is build on the heap, ...
> > That's why i need the inner working of new
> > There must be some info about that, no??

>
> the new operator is associated with dynamically created objects only.
>
> The compiler is responsible for dealing with how virtual functions and
> auto objects are allocated. This almost certainly has nothing to do
> with new.


But the pointer to the virtual table is located inside the object.
Doesn't new has to create the pointer (the place where it points to
can be chosen by the compiler).
 
Reply With Quote
 
Gianni Mariani
Guest
Posts: n/a
 
      10-29-2004
wijhierbeneden wrote:
> Gianni Mariani <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...

....
>>The compiler is responsible for dealing with how virtual functions and
>>auto objects are allocated. This almost certainly has nothing to do
>>with new.

>
>
> But the pointer to the virtual table is located inside the object.
> Doesn't new has to create the pointer (the place where it points to
> can be chosen by the compiler).


The constructor has this responsibility.
 
Reply With Quote
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      10-29-2004
wijhierbeneden wrote:
>
> Gianni Mariani <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> > wijhierbeneden wrote:
> > > Ron Natalie <(E-Mail Removed)> wrote in message news:<41815851$0$28303$(E-Mail Removed) om>...

> > ...
> > >
> > > Is there no info about the exact inner implementations available??
> > > That is what i want, i want to know how the Virtual table is created
> > > how the object is build on the heap, ...
> > > That's why i need the inner working of new
> > > There must be some info about that, no??

> >
> > the new operator is associated with dynamically created objects only.
> >
> > The compiler is responsible for dealing with how virtual functions and
> > auto objects are allocated. This almost certainly has nothing to do
> > with new.

>
> But the pointer to the virtual table is located inside the object.
> Doesn't new has to create the pointer (the place where it points to
> can be chosen by the compiler).


The purpose of new (if you write your own) is to get your
hands at some memory and return a pointer to it. For this new
is given the size of the requested memory. The details of
object construction in that memory are taken care of by the code
which calls new.

--
Karl Heinz Buchegger
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filtered Back Projection Algorithm (FBP Algorithm) Bapaiah Katepalli VHDL 1 06-23-2006 04:50 PM
Your thoughts on a new HiVR Panorama algorithm rob@19thparallel.com Digital Photography 5 05-24-2006 10:42 PM
New object-oriented parallel pattern matching algorithm bpontius@greateastsoftware.com C++ 10 10-31-2005 09:24 PM
Re: new algorithm Markus Elfring C++ 2 11-06-2004 02:04 PM
Key generation algorithm and Cipher algorithm Ahmed Moustafa Java 0 11-15-2003 06:35 AM



Advertisments