Changeset 1986 for trunk/src/kmk/misc.c
- Timestamp:
- Oct 28, 2008, 2:59:10 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/misc.c
r1971 r1986 398 398 if (result == 0) 399 399 fatal (NILF, _("virtual memory exhausted")); 400 400 401 #ifdef CONFIG_WITH_MAKE_STATS 401 402 make_stats_allocations++; 402 403 if (make_expensive_statistics) 403 { 404 unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result); 405 make_stats_allocated += actual_size; 406 make_stats_allocated_sum += actual_size; 407 } 404 make_stats_allocated += SIZE_OF_HEAP_BLOCK (result); 405 else 406 make_stats_allocated += size; 408 407 #endif 409 408 return result; … … 417 416 #ifdef CONFIG_WITH_MAKE_STATS 418 417 if (make_expensive_statistics && ptr != NULL) 419 {420 unsigned int actual_size = SIZE_OF_HEAP_BLOCK (ptr);421 make_stats_allocated -= actual_size;422 make_stats_allocated_sum -= actual_size;423 }418 make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr); 419 if (ptr) 420 make_stats_reallocations++; 421 else 422 make_stats_allocations++; 424 423 #endif 425 424 … … 430 429 if (result == 0) 431 430 fatal (NILF, _("virtual memory exhausted")); 431 432 432 #ifdef CONFIG_WITH_MAKE_STATS 433 if (!ptr)434 make_stats_allocations++;435 433 if (make_expensive_statistics) 436 { 437 unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result); 438 make_stats_allocated += actual_size; 439 make_stats_allocated_sum += actual_size; 440 } 434 make_stats_allocated += SIZE_OF_HEAP_BLOCK (result); 435 else 436 make_stats_allocated += size; 441 437 #endif 442 438 return result; … … 461 457 make_stats_allocations++; 462 458 if (make_expensive_statistics) 463 { 464 unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result); 465 make_stats_allocated += actual_size; 466 make_stats_allocated_sum += actual_size; 467 } 459 make_stats_allocated += SIZE_OF_HEAP_BLOCK (result); 460 else 461 make_stats_allocated += strlen (ptr) + 1; 468 462 #endif 469 463 #ifdef HAVE_STRDUP … … 1165 1159 } 1166 1160 1167 #if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP)1168 #undef free1169 void xfree(void *ptr)1170 {1171 if (ptr)1172 {1173 make_stats_allocations--;1174 if (make_expensive_statistics)1175 make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr);1176 free (ptr);1177 }1178 }1179 #endif1180 1181 1182 1161 #ifdef CONFIG_WITH_ALLOC_CACHES 1183 1162 … … 1403 1382 # endif /* __GLIBC__ */ 1404 1383 1384 # ifdef CONFIG_WITH_MAKE_STATS 1385 printf(_("# %lu malloc calls, %lu realloc calls\n"), 1386 make_stats_allocations, make_stats_reallocations); 1387 printf(_("# %lu MBs alloc sum, not counting freed, add pinch of salt\n"), /* XXX: better wording */ 1388 make_stats_allocated / (1024*1024)); 1389 # endif 1390 1405 1391 /* XXX: windows */ 1406 1392 }
Note:
See TracChangeset
for help on using the changeset viewer.