Date: Sun, 18 Jun 2000 16:56:49 +0100 From: Tim Robinson To: djgpp AT delorie DOT com Subject: Re: 'new ' operator problem In-Reply-To: <9617572459.20000619010132@mail.ru> References: <9617572459 DOT 20000619010132 AT mail DOT ru> Message-Id: <394CF141156.689DTIMOTHY.ROBINSON@hide> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver 1.25.07 Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk 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 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