gallium: Output the total of leaked memory.

This commit is contained in:
José Fonseca 2008-05-07 16:29:36 +09:00
parent c7ad942c54
commit 4d1bf8a85e
1 changed files with 8 additions and 1 deletions

View File

@ -211,6 +211,7 @@ debug_memory_begin(void)
void
debug_memory_end(unsigned long start_no)
{
size_t total_size = 0;
struct list_head *entry;
entry = list.prev;
@ -220,9 +221,15 @@ debug_memory_end(unsigned long start_no)
hdr = LIST_ENTRY(struct debug_memory_header, entry, head);
ptr = data_from_header(hdr);
if(start_no <= hdr->no && hdr->no < last_no ||
last_no < start_no && (hdr->no < last_no || start_no <= hdr->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);
total_size += hdr->size;
}
}
if(total_size) {
debug_printf("Total of %u KB of system memory apparently leaked\n",
(total_size + 1023)/1024);
}
}