1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nagachika 2012-01-11 14:09:10 +00:00
parent 2afa0b4cca
commit 28d28e844e
2 changed files with 15 additions and 3 deletions

View file

@ -1,3 +1,12 @@
Wed Jan 11 22:52:51 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
* 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.
Wed Jan 11 22:36:43 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com> Wed Jan 11 22:36:43 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
* test/readline/test_readline.rb (test_completion_proc_empty_result): * test/readline/test_readline.rb (test_completion_proc_empty_result):

5
gc.c
View file

@ -866,8 +866,10 @@ vm_xfree(rb_objspace_t *objspace, void *ptr)
size_t size; size_t size;
ptr = ((size_t *)ptr) - 1; ptr = ((size_t *)ptr) - 1;
size = ((size_t*)ptr)[0]; size = ((size_t*)ptr)[0];
if (size) {
objspace->malloc_params.allocated_size -= size; objspace->malloc_params.allocated_size -= size;
objspace->malloc_params.allocations--; objspace->malloc_params.allocations--;
}
#endif #endif
free(ptr); free(ptr);
@ -950,7 +952,8 @@ ruby_mimmalloc(size_t size)
#endif #endif
mem = malloc(size); mem = malloc(size);
#if CALC_EXACT_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; mem = (size_t *)mem + 1;
#endif #endif
return mem; return mem;