Mail Archives: djgpp/2000/06/18/11:15:04
Hi,
Well....i need to track every call of 'new' and 'delete' and store
info about it for debugging. The idea is: every 'new' stores info
about size, line (where it call), file (file where it call). Every
'delete' clear info for entered pointer. On exit i have a list of
'unfree' memory with number of lines and name of files where it was
called! I have next code:
#ifdef _DEBUG
#define DEBUG_NEW new(__FILE__, __LINE__)
#else
#define DEBUG_NEW new
#endif
#define new DEBUG_NEW
#ifdef _DEBUG
inline void * operator new(unsigned int size, const char *file, int line){};
inline void operator delete(void *p) {};
#endif
void main()
{
double *data;
data = new (double);
//delete data;
}
It's only example, there is no any real track, but there is idea.
Ok...i can't replace standard operator 'new' with my new with 3
arguments. It doesn't work. But it's clear and good code for Visual
C++, BC++, Watcom C++. But it doesn't work on DJGPP :(
It output something like '....is initializing like a variable'.
Ok....how i can track every call of 'new' and 'delete' and _store_
info about 'file and line' where this call was occurred? Have i any
chance to get it? Maybe by other ways...or i must use other compiler
for this task? :(
CUL8R, and please, answer to gayvoronsky AT mail DOT ru, if it will not be so
hard for you :)
- Raw text -