diff options
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -866,8 +866,10 @@ vm_xfree(rb_objspace_t *objspace, void *ptr) size_t size; ptr = ((size_t *)ptr) - 1; size = ((size_t*)ptr)[0]; - objspace->malloc_params.allocated_size -= size; - objspace->malloc_params.allocations--; + if (size) { + objspace->malloc_params.allocated_size -= size; + objspace->malloc_params.allocations--; + } #endif free(ptr); @@ -950,7 +952,8 @@ ruby_mimmalloc(size_t size) #endif mem = malloc(size); #if CALC_EXACT_MALLOC_SIZE - ((size_t *)mem)[0] = size; + /* set 0 for consistency of allocated_size/allocations */ + ((size_t *)mem)[0] = 0; mem = (size_t *)mem + 1; #endif return mem; |