Mail Archives: djgpp/2000/06/18/11:52:06
You could write your new and delete operators in Visual C++, as long as
you output to COFF format (the default) and don't use any Windows
functions. This seems to work on mine (Visual C++ 5).
On Mon, 19 Jun 2000 01:01:32 +1100
Andrey Gayvoronsky <gayvoronsky AT mail DOT ru> wrote:
> 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 :)
>
>
------------
Tim Robinson
timothy DOT robinson AT ic DOT ac DOT uk
- Raw text -