[pure-lang-svn] SF.net SVN: pure-lang: [95] pure/trunk/runtime.cc
Status: Beta
Brought to you by:
agraef
|
From: <ag...@us...> - 2008-05-17 20:06:45
|
Revision: 95
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=95&view=rev
Author: agraef
Date: 2008-05-17 13:06:47 -0700 (Sat, 17 May 2008)
Log Message:
-----------
Bugfixes in memory debugging code.
Modified Paths:
--------------
pure/trunk/runtime.cc
Modified: pure/trunk/runtime.cc
===================================================================
--- pure/trunk/runtime.cc 2008-05-17 19:45:28 UTC (rev 94)
+++ pure/trunk/runtime.cc 2008-05-17 20:06:47 UTC (rev 95)
@@ -21,6 +21,7 @@
// Debug expression allocations.
#if DEBUG>2
+int mem_level = 0;
set<pure_expr*> mem_allocations;
#if DEBUG>9
#define MEMDEBUG_NEW(x) mem_allocations.insert(x); \
@@ -31,15 +32,15 @@
#define MEMDEBUG_NEW(x) mem_allocations.insert(x);
#define MEMDEBUG_FREE(x) mem_allocations.erase(x);
#endif
-#define MEMDEBUG_INIT mem_allocations.clear();
-#define MEMDEBUG_SUMMARY(ret) mem_mark(ret); \
+#define MEMDEBUG_INIT if (mem_level++==0) mem_allocations.clear();
+#define MEMDEBUG_SUMMARY(ret) if (--mem_level==0) { mem_mark(ret); \
if (!mem_allocations.empty()) { cerr << "POSSIBLE LEAKS:\n"; \
for (set<pure_expr*>::iterator x = mem_allocations.begin(); \
x != mem_allocations.end(); x++) \
cerr << (void*)(*x) << " (refc = " << (*x)->refc << "): " \
<< (*x) << endl; \
mem_allocations.clear(); \
- }
+ } }
static void mem_mark(pure_expr *x)
{
mem_allocations.erase(x);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|