free(mem_ref);
}
-
static void add_mem_info(void *mem_ref, unsigned int size, const char *file, unsigned int line) {
- SYNCHRONIZE(synchronized);
+ #ifdef HAVE_THREADS
+ pthread_mutex_lock(&synchronized);
+ #endif
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.line = line;
mem_leak_info->next = ptr_start;
ptr_start = mem_leak_info;
- DESYNCHRONIZE(synchronized);
+ #ifdef HAVE_THREADS
+ pthread_mutex_unlock(&synchronized);
+ #endif
}
static void remove_mem_info(void *mem_ref) {
- SYNCHRONIZE(synchronized);
+ #ifdef HAVE_THREADS
+ pthread_mutex_lock(&synchronized);
+ #endif
struct MemoryLeak *leak_info, *next, *prev = NULL;
for(leak_info = ptr_start; leak_info; leak_info = next) {
next = leak_info->next;
} else
prev = leak_info;
}
- DESYNCHRONIZE(synchronized);
+ #ifdef HAVE_THREADS
+ pthread_mutex_unlock(&synchronized);
+ #endif
}
void initMemoryDebug() {
}
struct memoryInfoFiles *getMemoryInfoFiles() {
- SYNCHRONIZE(synchronized);
+ #ifdef HAVE_THREADS
+ pthread_mutex_lock(&synchronized);
+ #endif
struct MemoryLeak *leak_info;
struct memoryInfoFiles *list = NULL, *element;
for(leak_info = ptr_start; leak_info != NULL; leak_info = leak_info->next) {
element->allocated = own_allocated_memleaks * sizeof(struct MemoryLeak);
element->next = list;
list = element;
- DESYNCHRONIZE(synchronized);
+ #ifdef HAVE_THREADS
+ pthread_mutex_unlock(&synchronized);
+ #endif
return list;
}
}
struct memoryInfoLines *getMemoryInfoLines(const char *filename) {
- SYNCHRONIZE(synchronized);
+ #ifdef HAVE_THREADS
+ pthread_mutex_lock(&synchronized);
+ #endif
struct MemoryLeak *leak_info;
struct memoryInfoLines *list = NULL, *element;
for(leak_info = ptr_start; leak_info != NULL; leak_info = leak_info->next) {
element->next = list;
list = element;
}
- DESYNCHRONIZE(synchronized);
+ #ifdef HAVE_THREADS
+ pthread_mutex_unlock(&synchronized);
+ #endif
return list;
}