This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: malloc vs. new
- From: Pierre Merlin <pierre dot merlin at clarus-networks dot fr>
- To: ecos-discuss at sources dot redhat dot com
- Date: Mon, 24 Jun 2002 12:19:56 +0200
- Subject: Re: [ECOS] malloc vs. new
- Organization: Clarus Networks
- References: <Pine.LNX.4.44.0206221724340.23249-100000@ruckus.brouhaha.com>
- Reply-to: ecos-discuss at sources dot redhat dot com
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