memory (961B)
1 #ifndef _MEMORY_ 2 #define _MEMORY_ 3 4 #include "sys/sys" 5 #include "ThreadsAndMutexes/mutex/mutex" 6 7 class Memory { 8 public: 9 // Memory accessing functions 10 static void *malloc(size_t sz, string const &desc = ""); 11 static void *realloc(void *ptr, size_t newsz, string const &desc = ""); 12 static void free(void *ptr); 13 static void *operator new(size_t sz); 14 static void operator delete(void *ptr); 15 static void *operator new[](size_t sz); 16 static void operator delete[](void *ptr); 17 18 // Follow actions immediately? 19 static void mem_follow(bool b); 20 static bool mem_follow(); 21 22 // Dump what we have 23 static void mem_display(); 24 25 // Marker in the overview 26 static void mem_mark(string const &desc = ""); 27 28 // Internal storage types 29 struct MemoryEntry { 30 void *ptr; 31 size_t sz; 32 string desc; 33 }; 34 typedef vector<MemoryEntry> MemoryLog; 35 private: 36 static MemoryLog s_memlog; 37 static bool s_follow; 38 }; 39 40 #endif