summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2008-04-08 11:30:36 +0900
committerJosé Fonseca <[email protected]>2008-04-08 12:04:03 +0900
commit4e2127b0e5cb6411123e16dd562626cd70814a9a (patch)
tree49ab5d3a0a5978f62ccfde2918f4159c1819c79d /src/gallium/auxiliary/util
parent985134211d9fbfe9b7885beeeb85fdcf2ab78f87 (diff)
gallium: Allow to debug memory leaks in nested scopes.
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/p_debug_mem.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/gallium/auxiliary/util/p_debug_mem.c b/src/gallium/auxiliary/util/p_debug_mem.c
index c160afe5b7f..97ec9c5b392 100644
--- a/src/gallium/auxiliary/util/p_debug_mem.c
+++ b/src/gallium/auxiliary/util/p_debug_mem.c
@@ -70,8 +70,7 @@ struct debug_memory_header
static struct list_head list = { &list, &list };
-static unsigned long start_no = 0;
-static unsigned long end_no = 0;
+static unsigned long last_no = 0;
void *
@@ -84,7 +83,7 @@ debug_malloc(const char *file, unsigned line, const char *function,
if(!hdr)
return NULL;
- hdr->no = end_no++;
+ hdr->no = last_no++;
hdr->file = file;
hdr->line = line;
hdr->function = function;
@@ -147,14 +146,14 @@ debug_realloc(const char *file, unsigned line, const char *function,
return new_ptr;
}
-void
-debug_memory_reset(void)
+unsigned long
+debug_memory_begin(void)
{
- start_no = end_no;
+ return last_no;
}
void
-debug_memory_report(void)
+debug_memory_end(unsigned long start_no)
{
struct list_head *entry;
@@ -164,7 +163,8 @@ debug_memory_report(void)
void *ptr;
hdr = LIST_ENTRY(struct debug_memory_header, entry, head);
ptr = (void *)((char *)hdr + sizeof(*hdr));
- if(hdr->no >= start_no)
+ if(start_no <= hdr->no && hdr->no < last_no ||
+ last_no < start_no && (hdr->no < last_no || start_no <= hdr->no))
debug_printf("%s:%u:%s: %u bytes at %p not freed\n",
hdr->file, hdr->line, hdr->function,
hdr->size, ptr);