diff options
author | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:29 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:29 +0200 |
commit | eaf11cc12a1aa4b050a8a1e7ea3770d3d9c81e95 (patch) | |
tree | 833f3fae6e3604a439f909c245a6e35f574997d7 /DebugMemory.c | |
parent | 283707c5e5bc436b78ea23bf5500cb6b16a01148 (diff) | |
download | debian_htop-eaf11cc12a1aa4b050a8a1e7ea3770d3d9c81e95.tar.gz debian_htop-eaf11cc12a1aa4b050a8a1e7ea3770d3d9c81e95.tar.bz2 debian_htop-eaf11cc12a1aa4b050a8a1e7ea3770d3d9c81e95.zip |
Imported Upstream version 1.0upstream/1.0
Diffstat (limited to 'DebugMemory.c')
-rw-r--r-- | DebugMemory.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/DebugMemory.c b/DebugMemory.c index da2bf62..7a0f584 100644 --- a/DebugMemory.c +++ b/DebugMemory.c @@ -1,5 +1,4 @@ -#define _GNU_SOURCE #include <string.h> #include <stdlib.h> #include <stdio.h> @@ -90,7 +89,7 @@ void* DebugMemory_realloc(void* ptr, int size, char* file, int line, char* str) return data; } -void* DebugMemory_strdup(char* str, char* file, int line) { +void* DebugMemory_strdup(const char* str, char* file, int line) { assert(str); char* data = strdup(str); DebugMemory_registerAllocation(data, file, line); @@ -102,7 +101,7 @@ void* DebugMemory_strdup(char* str, char* file, int line) { } void DebugMemory_free(void* data, char* file, int line) { - assert(data); + if (!data) return; DebugMemory_registerDeallocation(data, file, line); if (singleton->file) { if (singleton->totals) fprintf(singleton->file, "%d\t", singleton->size); @@ -209,7 +208,10 @@ void DebugMemory_report() { assert(walk->magic == 11061980); i++; fprintf(stderr, "%p %s:%d\n", walk->data, walk->file, walk->line); + DebugMemoryItem* old = walk; walk = walk->next; + free(old->file); + free(old); } fprintf(stderr, "Total:\n"); fprintf(stderr, "%d allocations\n", singleton->allocations); @@ -218,6 +220,7 @@ void DebugMemory_report() { fprintf(stderr, "%d non-freed blocks\n", i); if (singleton->file) fclose(singleton->file); + free(singleton); } #elif defined(DEBUGLITE) |