c++ - Stop calling overloaded new and delete operator by stl containers -


i developing memoryleak tool. in overloading new , delete operator. working fine. code creating tool around 15000 lines. cannot change existing code can invoke memoryleak tool function existing code. existing code having stl containers (like list, map, stack etc). stl container call new , delete operator allocate or deallocate memory. want stl container should call new , delete operator in not overloaded new , delete. ex:

int *iptr = new int[10] ----> should call overloaded new[] delete [] iptr -------------> should call overloaded delete[] map.insert(10) -------------> should call default new[] ( in new.h) map.erase()  ---------------> should call default delete[] ( in new.h) 

how can it? aprreciated.

sorry forgot mention replacing new , delete following macros:

#define new debug_new #define debug_new trackmemory(__file__, __line__) ->* new #define delete trackdelete(__file__, __line__); delete 

here trackmemory used track memory , new used allocate memory same delete. tool works fine when stl containers comes picture gives wrong result because use overloaded new. please me out

15000 lines ? well, replace calls new , delete calls wrapper methods in code (using macros log __file__ , __line__ can first step) , you'll done quickly.

or use existing tool, valgrind.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -