projects
/
NeonServV5.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
75fed87
)
added memoryDebug.c memory info to cmd_meminfo
author
pk910
<philipp@zoelle1.de>
Mon, 30 Jan 2012 16:49:18 +0000
(17:49 +0100)
committer
pk910
<philipp@zoelle1.de>
Mon, 30 Jan 2012 16:49:18 +0000
(17:49 +0100)
src/memoryDebug.c
patch
|
blob
|
history
diff --git
a/src/memoryDebug.c
b/src/memoryDebug.c
index 442e618e1dfe0dbbf144d387bc82bcf947db1151..e870f4ba4854f2253a1b424b41c7b71a91dc0f81 100644
(file)
--- a/
src/memoryDebug.c
+++ b/
src/memoryDebug.c
@@
-44,6
+44,8
@@
static pthread_mutex_t synchronized;
static struct MemoryLeak *ptr_start = NULL;
static struct MemoryLeak *ptr_start = NULL;
+static unsigned int own_allocated_memleaks = 0;
+
static void add_mem_info(void * mem_ref, unsigned int size, const char *file, unsigned int line);
static void remove_mem_info(void * mem_ref);
static void add_mem_info(void * mem_ref, unsigned int size, const char *file, unsigned int line);
static void remove_mem_info(void * mem_ref);
@@
-81,7
+83,8
@@
void xfree(void *mem_ref) {
static void add_mem_info(void *mem_ref, unsigned int size, const char *file, unsigned int line) {
SYNCHRONIZE(synchronized);
static void add_mem_info(void *mem_ref, unsigned int size, const char *file, unsigned int line) {
SYNCHRONIZE(synchronized);
- struct MemoryLeak *mem_leak_info = malloc (sizeof(*mem_leak_info));
+ struct MemoryLeak *mem_leak_info = malloc(sizeof(*mem_leak_info));
+ own_allocated_memleaks++;
mem_leak_info->mem_info.address = mem_ref;
mem_leak_info->mem_info.size = size;
strcpy(mem_leak_info->mem_info.file_name, file);
mem_leak_info->mem_info.address = mem_ref;
mem_leak_info->mem_info.size = size;
strcpy(mem_leak_info->mem_info.file_name, file);
@@
-101,6
+104,7
@@
static void remove_mem_info(void *mem_ref) {
prev->next = next;
else
ptr_start = next;
prev->next = next;
else
ptr_start = next;
+ own_allocated_memleaks--;
free(leak_info);
break;
} else
free(leak_info);
break;
} else
@@
-163,8
+167,14
@@
struct memoryInfoFiles *getMemoryInfoFiles() {
element->allocations += 1;
element->allocated += leak_info->mem_info.size;
}
element->allocations += 1;
element->allocated += leak_info->mem_info.size;
}
+ element = malloc(sizeof(*element));
+ element->filename = strdup(__FILE__);
+ element->allocations = own_allocated_memleaks;
+ element->allocated = own_allocated_memleaks * sizeof(struct MemoryLeak);
+ element->next = list;
+ list = element;
DESYNCHRONIZE(synchronized);
DESYNCHRONIZE(synchronized);
- return
elemen
t;
+ return
lis
t;
}
void freeMemoryInfoFiles(struct memoryInfoFiles *files) {
}
void freeMemoryInfoFiles(struct memoryInfoFiles *files) {
@@
-197,8
+207,16
@@
struct memoryInfoLines *getMemoryInfoLines(const char *filename) {
}
element->allocations++;
}
}
element->allocations++;
}
+ if(!stricmp(filename, __FILE__)) {
+ element = malloc(sizeof(*element));
+ element->line = 0;
+ element->allocations = own_allocated_memleaks;
+ element->allocate = sizeof(struct MemoryLeak);
+ element->next = list;
+ list = element;
+ }
DESYNCHRONIZE(synchronized);
DESYNCHRONIZE(synchronized);
- return
elemen
t;
+ return
lis
t;
}
void freeMemoryInfoLines(struct memoryInfoLines *lines) {
}
void freeMemoryInfoLines(struct memoryInfoLines *lines) {