summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-11 14:09:10 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-11 14:09:10 +0000
commit28d28e844e58d0f6f17866b4fae5db19cba805db (patch)
treefd21183797d4b5b902f599fce50ec09377a8a105 /gc.c
parent2afa0b4ccaeef334b897ad33ddd4f36c7e51dbf9 (diff)
* gc.c (ruby_mimmalloc): don't set allocated size to header.
ruby_mimmalloc() doesn't increment allocated_size/allocations and decrement them in ruby_xfree() cause inconsistency. * gc.c (ruby_xfree): don't decrement allocated_size/allocations if allocated size record is 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gc.c b/gc.c
index 6ce83469e6..5aac9738e3 100644
--- a/gc.c
+++ b/gc.c
@@ -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;