Skip to content

Instantly share code, notes, and snippets.

@karimnaaji
Created June 16, 2015 22:34
Show Gist options
  • Save karimnaaji/e8ca6c52682594bb1212 to your computer and use it in GitHub Desktop.
Save karimnaaji/e8ca6c52682594bb1212 to your computer and use it in GitHub Desktop.
track c++ allocations
global operator new
global operator new []
global operator delete
global operator delete []
#undef new
void *operator new (size_t size, char *file, int line, char *function);
// [...]
#define new new (__FILE__, __LINE__, __FUNCTION__)
// implementation
void *operator new (size_t size, char *file, int line, char *function) {
// tracking code
return malloc (size);
}
// [...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment