diff options
author | Eugene V. Lyubimkin <jackyf@debian.org> | 2011-11-26 15:58:33 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:30 +0200 |
commit | c65eb8be811f59b55d64d9e7654c33708de79ad9 (patch) | |
tree | ee6e542b988263c49f0e1200d6aa5aa635667fe8 /DebugMemory.c | |
parent | 38174fffd79f54a8be7642bf170a2320b29e8063 (diff) | |
parent | eaf11cc12a1aa4b050a8a1e7ea3770d3d9c81e95 (diff) | |
download | debian_htop-debian/1.0-1.tar.gz debian_htop-debian/1.0-1.tar.bz2 debian_htop-debian/1.0-1.zip |
Imported Debian patch 1.0-1debian/1.0-1
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) |