extern unsigned int _gCurLine; extern char* _gCurFile;
#define MEM_FUNC_CALL _gCurLine=__LINE__; _gCurFile=(char*)__FILE__;

For instance, try the following code:
#include "MemoryHandler.h"
#include <iostream>
class A { };
class B {
public:
B() { MEM_FUNC_CALL a = new A(); }
~B() { MEM_FUNC_CALL delete a; }
private:
B( const B& );
B& operator= ( const B& );
private:
A* a;
};
int main( int, char*[] ) {
B* b = 0;
if ( false )
MEM_FUNC_CALL b = new B;
EndOfProgramMemCheck();
}
You can also override new and new[] to include additional parameters and use a macro to hijack all calls to new and delete to call your overloaded version, without needing to remember to use MEM_FUNC_CALL. (Though, you do need to make sure that the macros are defined in each compilation unit.) Take a look at a demonstration of memory leak detection for Visual Studio on MSDN. It should give you some ideas.
Also:
Those aren't trees, those are linked lists :|
