home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: cvnet.c++,comp.lang.c++
- Path: sparky!uunet!mcsun!sunic!aun.uninett.no!nuug!nntp.uio.no!boeygen!bosnes
- From: bosnes@boeygen.nr.no (Vidar Bosnes)
- Subject: Re: Finding memory leaks
- Message-ID: <1992Nov21.145321.2297@ulrik.uio.no>
- Keywords: OOP,memory leaks
- Sender: bosnes@boeygen (Vidar Bosnes)
- Nntp-Posting-Host: boeygen.nr.no
- Organization: Norsk Regnesentral (NR)
- References: <1992Nov20.191828.14500@ultb.isc.rit.edu>
- Date: Sat, 21 Nov 1992 14:53:21 GMT
- Lines: 19
-
- Mike Kirby (mpk9172@ultb.isc.rit.edu) writes:
- > I would like to do the same kind of thing in C++. Unfortunately, it
- > seems that new is not as easy to #define over as malloc. I thought
- > (briefly) that I could do something like #define new new(__LINE__,__FILE__)
- > and then overload the new operator, but this causes a recursive macro.
-
- There should be no problem in using the macro you suggested. The ARM
- (chap 16.3.3), Preprocessing; rescanning and further replacement, reads:
-
- After all parameters in the replacement list have been replaced, the
- resulting list is rescanned for more macros to replace. If the name
- of the macro being replaced is found during this scan or during
- subsequent rescanning, it is not replaced.
-
- Thus, there is no recursion involved. I have used this technique
- successfully with g++ and dec-cxx. If you use g++, note that this
- compiler uses non-standard syntax for the call to the overloaded
- new-operator (curly braces instead of parentheses).
-
-