small fixes

This commit is contained in:
daan 2020-04-07 10:40:19 -07:00
parent 6b6a8a2315
commit a0d7a9d94d
2 changed files with 5 additions and 5 deletions

View File

@ -282,13 +282,13 @@ typedef struct mi_heap_area_s {
size_t block_size; // size in bytes of each block size_t block_size; // size in bytes of each block
} mi_heap_area_t; } mi_heap_area_t;
// Information about a block // Information about an allocated block.
typedef struct mi_block_info_s { typedef struct mi_block_info_s {
void* block; // start of the block void* block; // start of the block
size_t size; // full size including padding etc. size_t size; // full size including padding etc.
size_t usable_size; // usable size (available for in-place realloc) size_t usable_size; // usable size (available for in-place realloc)
size_t allocated_size; // actual allocated size (only precise in debug mode with padding) size_t allocated_size; // actual allocated size (only precise in debug mode with padding enabled)
bool valid; // is the block valid? (only detects corrupt blocks with padding enabled) bool valid; // is the block valid? (only detects heap overflow with padding enabled)
mi_source_t source; // the source location that allocated this block (only valid in debug mode with padding) mi_source_t source; // the source location that allocated this block (only valid in debug mode with padding)
} mi_block_info_t; } mi_block_info_t;

View File

@ -608,13 +608,13 @@ void mi_heap_print_json(mi_heap_t* heap, mi_output_fun* out, void* arg) {
bool mi_heap_is_empty(mi_heap_t* heap) { bool mi_heap_is_empty(mi_heap_t* heap) {
if (heap==NULL) heap = mi_heap_get_default(); if (heap==NULL) heap = mi_heap_get_default();
mi_collect(false); mi_heap_collect(heap,false);
return (heap->page_count == 0); return (heap->page_count == 0);
} }
void mi_heap_check_leak(mi_heap_t* heap, mi_output_fun* out, void* arg) { void mi_heap_check_leak(mi_heap_t* heap, mi_output_fun* out, void* arg) {
if (!mi_heap_is_empty(heap)) { if (!mi_heap_is_empty(heap)) {
_mi_fprintf(out,arg,"mimalloc: potential memory leak detected. Current heap blocks:\n"); _mi_fprintf(out,arg,"mimalloc: potential memory leak detected; current heap blocks:\n");
mi_heap_print_json(heap, out, arg); mi_heap_print_json(heap, out, arg);
} }
} }