On Tue, 18 May 2004 09:22:44 +0100, Bryan O'Donoghue <bryano at europlex.ie>
wrote:
> I seem to remember in a late night meander that "new" is actually when
> you get right down to it, some sort of overloaded call to "malloc" and
> "delete" is some sort of overloaded call to "free".
Not an overload; implemented in terms of.
Not always, but on unix this is the way most C++ compilers
writers implement new and delete.
What you can do instead, if you don't like the defaults, is to
write your own operator new and operator delete.
> Assuming that's true, what would be the effect of linking against
> Electric Fence here, with it's replacements for malloc and free?
Try it, but it should work fine.
> My instinct tells me that, the libc malloc & free if overloaded at the
> C++ compiler level, *won't* be replaced, but, I might be wrong.
I see what you're saying, but it's not an overload. Load up a C++
program in gdb and step into the new call or use strace. Chances
are, you will see a standard glibc malloc call being made.
If you want to know more about this topic, Scott Meyers' Effective
C++ books are a good starting point, but the bottom line is that
on unix, new and delete ultimately resolve to standard malloc/free
calls.
Dermot.
--
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!