Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!elroy!peregrine!zardoz!tgate!irsx01!ka3ovk!drilex!axiom!linus!alliant!palladium!bby From: bby@palladium.UUCP (Bob Mastors) Newsgroups: comp.lang.c++ Subject: memory allocation watching Keywords: new malloc Message-ID: <710@palladium.UUCP> Date: 8 Jun 89 17:22:22 GMT Organization: Epoch Systems, Marlboro MA Lines: 28 If you have wrapper routines around malloc/realloc/free, like I do, and like to pass in __LINE__ and __FILE__ to see what part of the program is messing up, then you may have been wondering how to pass __LINE__ and __FILE__ to your wrapper routines when new and delete is called. A solution is to put the following in an include file and change all of your "new" references to "tnew": extern int curline; extern char *curfile; #define tnew (!((curline = __LINE__), (curfile = __FILE__))) ? 0 : new If you have a cpp that is trying to conform to the ANSI C draft then you can call it new instead of tnew and you won't get recursion on the macro. You will need your own version of _new that passes curfile and curline to your wrapper routine that calls malloc. And of course you will want to duplicate all this for the delete operator. --- Bob Mastors Epoch Systems, Marlboro MA (508) 481-3717 {linus!alliant, harvard!cfisun}!palladium!bby -- --- Bob Mastors Epoch Systems, Marlboro MA (508) 481-3717 {linus!alliant, harvard!cfisun}!palladium!bby