This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: malloc vs. new


Hi Scott,

On Sunday 23 June 2002 03:03, Scott Dattalo wrote:
> On Sat, 22 Jun 2002, Dan Conti wrote:
> > 1) write your own operator new/new[]/delete/delete[]. tossing the
> > following into some file should work:
>
> I thought about this, but when you overload new and delete the constructor
> is no longer called (actually, that's an assumption on my part). So I'll
> have to add special code to initialize the objects as they're new'd.

I think your assumption is wrong. IIRC, when you call _ new _, it always 
works as follows :
1) allocates memory space, using operator new  
2) initializes the object(s) being created, using the constructor

Pay attention to this distinction between the NOT overloadable new and the 
operator new, which you can redefine at your convenience.

Regards,
Pierre

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]