Path: chuka.playstation.co.uk!news From: "Simon P. Bullen" Newsgroups: scea.yaroze.programming.codewarrior Subject: Re: malloc/free/new and delete Date: Thu, 06 Aug 1998 19:01:12 +1000 Organization: Continental Laboratories Lines: 33 Message-ID: <35C970D8.8953E503@bigpond.com> References: <01bc8513$4e939960$9fbf43ce@wkwerner> Reply-To: simonb@geocities.com NNTP-Posting-Host: EXIP-T-003-p-204-144.tmns.net.au Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.05 [en] (WinNT; I) > 2) There were a couple of bugs that we found at the last minute that were > only related to C++. Since most of the Yaroze programmers right now are > using straight C, we elected to temporarily remove C++ support from the > tools (by removing the runtime library. If you wish to use C++, you can > do so by writing your own new() and delete() functions that map to > malloc() and free()) Incidentally, the supplied C++ runtime library's version of delete crashes when you attempt to delete a null pointer, which is supposed to be safe. Also, using the standard C++ way of overloading new and delete does not compile, but this can be worked around by providing functions something like this: void __dl( void *uptr ) { if( uptr != NULL ) free( uptr ); } void __nw( size_t size ) { return malloc(size); } I used this technique to get Fortify working under CodeWarrior for C and C++. For those who have not heard of Fortify, it is a library that wraps around malloc/free/new/delete to detect leaks, overwrites, and all manner of memory related bugs. Get your copy now from http://www.geocities.com/SiliconValley/Horizon/8596/ The next official release of Fortify will include the CodeWarrior fixes. Drop me an e-mail if you're interested in using this, and it might encourage me to finish off the rest of the stuff I have to do before version 2.3 can be released :-). GCC users should be able to use version 2.2, though I haven't tried the Yaroze version of GCC specifically. spb