www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/18/11:15:04

Date: Mon, 19 Jun 2000 01:01:32 +1100
From: Andrey Gayvoronsky <gayvoronsky AT mail DOT ru>
X-Mailer: The Bat! (v1.44) UNREG / CD5BF9353B3B7091
X-Priority: 3 (Normal)
Message-ID: <9617572459.20000619010132@mail.ru>
To: djgpp AT delorie DOT com
Subject: 'new ' operator problem
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019