| 245 | #endif |
| 246 | |
| 247 | ACL_DEBUG_MEM *acl_debug_malloc_init(ACL_DEBUG_MEM *debug_mem_ptr, const char *dump_file) |
| 248 | { |
| 249 | ACL_DEBUG_MEM *mem; |
| 250 | if (debug_mem_ptr != NULL) { |
| 251 | __debug_mem = mem = debug_mem_ptr; |
| 252 | } else { |
| 253 | ASSERT(dump_file && *dump_file); |
| 254 | |
| 255 | mem = (ACL_DEBUG_MEM*) calloc(1, sizeof(ACL_DEBUG_MEM)); |
| 256 | acl_assert(mem); |
| 257 | __debug_mem = mem; |
| 258 | __debug_mem->dump_fp = fopen(dump_file, "wb+"); |
| 259 | ASSERT(__debug_mem->dump_fp); |
| 260 | __debug_mem->table = debug_htable_create(1000); |
| 261 | ASSERT(__debug_mem->table); |
| 262 | acl_pthread_mutex_init(&__debug_mem->lock, NULL); |
| 263 | #ifndef HAVE_NO_ATEXIT |
| 264 | atexit(debug_dump_atexit); |
| 265 | #endif |
| 266 | fprintf(__debug_mem->dump_fp, "begin set mem_hook\n"); |
| 267 | fflush(__debug_mem->dump_fp); |
| 268 | } |
| 269 | |
| 270 | acl_mem_hook(acl_debug_malloc, |
| 271 | acl_debug_calloc, |
| 272 | acl_debug_realloc, |
| 273 | acl_debug_strdup, |
| 274 | acl_debug_strndup, |
| 275 | acl_debug_memdup, |
| 276 | acl_debug_free); |
| 277 | |
| 278 | return mem; |
| 279 | } |
no test coverage detected
searching dependent graphs…