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) {
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);
prev->next = next;
else
ptr_start = next;
+ own_allocated_memleaks--;
free(leak_info);
break;
} else
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);
- return element;
+ return list;
}
void freeMemoryInfoFiles(struct memoryInfoFiles *files) {
}
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);
- return element;
+ return list;
}
void freeMemoryInfoLines(struct memoryInfoLines *lines) {