home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16697 < prev    next >
Encoding:
Text File  |  1992-11-21  |  1.4 KB  |  33 lines

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