I am developing a memoryleak tool. In this, I overload the new and deleting operator. His work is wonderful. But the code for which I am creating this tool is about 15,000 lines. I canβt modify the existing code, I can call the memoryleak tool function in the existing code. Existing code with stl containers (e.g. list, map, stack, etc.). The Stl container also calls the new and delete statements to allocate or free memory. I want the stl container to call the new and delete operator, which was not overloaded with the new one and deleted it. for ex:
int *iptr = new int[10] ----> should call overloaded new[]
delete [] iptr -------------> should call overloaded delete[]
map.insert(10) -------------> should call default new[] ( which are in new.h)
map.erase() ---------------> should call default delete[] ( which are in new.h)
How can i do this? Any help would be appreciated.
Sorry to forget to mention that I am replacing a new one and deleting using the following macros:
#define new DEBUG_NEW
#define DEBUG_NEW TrackMemory(__FILE__, __LINE__) ->* new
#define delete TrackDelete(__FILE__, __LINE__); delete
TrackMemory , .
, stl- , , .
,