TeaSpeakLibrary/src/misc/memtracker.h

30 lines
713 B
C
Raw Normal View History

2019-06-26 16:11:22 -04:00
#pragma once
#include <string>
#include <typeinfo>
namespace memtrack {
#define TRACK_OBJECT_ALLOCATION
#ifdef TRACK_OBJECT_ALLOCATION
2020-01-23 20:49:59 -05:00
extern void allocated(const char* name, void* address);
extern void freed(const char* name, void* address);
template <typename T>
void allocated(void* address) { allocated(typeid(T).name(), address); }
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
template <typename T>
void freed(void* address) { freed(typeid(T).name(), address); }
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
void statistics();
2019-06-26 16:11:22 -04:00
#else
2020-01-23 20:49:59 -05:00
template <typename... T>
inline void __empty(...) { }
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
#define freed __empty
#define allocated __empty
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
#define allocated_mangled __empty
#define freed_mangled __empty
2019-06-26 16:11:22 -04:00
2020-01-23 20:49:59 -05:00
inline void statistics() {}
2019-06-26 16:11:22 -04:00
#endif
}