summaryrefslogtreecommitdiff
path: root/lib/common/MemLeakFinder.h
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2006-11-13 16:07:36 +0000
committerChris Wilson <chris+github@qwirx.com>2006-11-13 16:07:36 +0000
commitc26856da8e344e7ec94d55f92ed49a09f04c5769 (patch)
treed0b1ac1ad274e27a93844ebb4848584c0c538f58 /lib/common/MemLeakFinder.h
parentab0b5628af0aaf7851a4ca377a25ed569d4112c2 (diff)
* Track memory leaks in allocations via the standard libraries, and
avoid malloc/delete mismatches, by overriding standard new operator. * Added another global enable flag to memleak finder, which is used to mark the end of static allocations and the start of dynamic code, since the memory leak detection is done before cleanup of static objects. * Added a public guard class, to allow safe scoped disabling of memory leak detection. * Added InternalAllocGuard to protect against recursive loops when allocating memory inside the memory leak checker. (refs #3)
Diffstat (limited to 'lib/common/MemLeakFinder.h')
-rw-r--r--lib/common/MemLeakFinder.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/common/MemLeakFinder.h b/lib/common/MemLeakFinder.h
index f5887dac..f47a38aa 100644
--- a/lib/common/MemLeakFinder.h
+++ b/lib/common/MemLeakFinder.h
@@ -20,6 +20,13 @@
// global enable flag
extern bool memleakfinder_global_enable;
+class MemLeakSuppressionGuard
+{
+ public:
+ MemLeakSuppressionGuard();
+ ~MemLeakSuppressionGuard();
+};
+
extern "C"
{
void *memleakfinder_malloc(size_t size, const char *file, int line);
@@ -27,6 +34,8 @@ extern "C"
void memleakfinder_free(void *ptr);
}
+void memleakfinder_init();
+
int memleakfinder_numleaks();
void memleakfinder_reportleaks();
@@ -41,10 +50,12 @@ void memleakfinder_traceblocksinsection();
void memleakfinder_notaleak(void *ptr);
-void *operator new(size_t size, const char *file, int line);
+void *operator new (size_t size, const char *file, int line);
void *operator new[](size_t size, const char *file, int line);
+void *operator new (size_t size);
+void *operator new[](size_t size);
-void operator delete(void *ptr) throw ();
+void operator delete (void *ptr) throw ();
void operator delete[](void *ptr) throw ();
// define the malloc functions now, if required
@@ -55,6 +66,5 @@ void operator delete[](void *ptr) throw ();
#define MEMLEAKFINDER_MALLOC_MONITORING_DEFINED
#endif
-
#endif // MEMLEAKFINDER__H