- added leak_dumper header all over the place (not yet functional in linux)

- Bugfix for particle cleanup
This commit is contained in:
Mark Vejvoda
2010-09-07 05:25:40 +00:00
parent 5fdbce7651
commit ab44c83168
159 changed files with 3109 additions and 55 deletions

View File

@@ -17,8 +17,13 @@
#ifdef SL_LEAK_DUMP
#include <new>
//#include <memory>
#include <cstdlib>
#include <cstdio>
//#include <cstddef>
using namespace std;
//including this header in any file of a project will cause all
//leaks to be dumped into leak_dump.txt, but only allocations that
@@ -68,48 +73,48 @@ public:
//if an allocation ocurrs in a file where "leaks_dumper.h" is not included
//this operator new is called and file and line will be unknown
inline void * operator new (size_t bytes){
void * operator new (size_t bytes) {
void *ptr= malloc(bytes);
AllocRegistry::getInstance().allocate(AllocInfo(ptr, "unknown", 0, bytes, false));
return ptr;
}
inline void operator delete(void *ptr){
void operator delete(void *ptr){
AllocRegistry::getInstance().deallocate(ptr, false);
free(ptr);
}
inline void * operator new[](size_t bytes){
void * operator new[](size_t bytes){
void *ptr= malloc(bytes);
AllocRegistry::getInstance().allocate(AllocInfo(ptr, "unknown", 0, bytes, true));
return ptr;
}
inline void operator delete [](void *ptr){
void operator delete [](void *ptr){
AllocRegistry::getInstance().deallocate(ptr, true);
free(ptr);
}
//if an allocation ocurrs in a file where "leaks_dumper.h" is included
//this operator new is called and file and line will be known
inline void * operator new (size_t bytes, char* file, int line){
void * operator new (size_t bytes, char* file, int line){
void *ptr= malloc(bytes);
AllocRegistry::getInstance().allocate(AllocInfo(ptr, file, line, bytes, false));
return ptr;
}
inline void operator delete(void *ptr, char* file, int line){
void operator delete(void *ptr, char* file, int line){
AllocRegistry::getInstance().deallocate(ptr, false);
free(ptr);
}
inline void * operator new[](size_t bytes, char* file, int line){
void * operator new[](size_t bytes, char* file, int line){
void *ptr= malloc(bytes);
AllocRegistry::getInstance().allocate(AllocInfo(ptr, file, line, bytes, true));
return ptr;
}
inline void operator delete [](void *ptr, char* file, int line){
void operator delete [](void *ptr, char* file, int line){
AllocRegistry::getInstance().deallocate(ptr, true);
free(ptr);
}
@@ -118,4 +123,5 @@ inline void operator delete [](void *ptr, char* file, int line){
#endif
#endif