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 *
if(!hdr)
return NULL;
- hdr->no = end_no++;
+ hdr->no = last_no++;
hdr->file = file;
hdr->line = line;
hdr->function = 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;
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);
debug_realloc(const char *file, unsigned line, const char *function,
void *old_ptr, size_t old_size, size_t new_size );
-void
-debug_memory_reset(void);
+unsigned long
+debug_memory_begin(void);
void
-debug_memory_report(void);
+debug_memory_end(unsigned long beginning);
#ifdef __cplusplus