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

fix allocated_size

* gc.c (vm_xrealloc): fix allocated_size update, should not ignore old
  size.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-07-03 05:37:29 +00:00
parent 1f23350194
commit c7c397f917

7
gc.c
View file

@ -832,6 +832,9 @@ static void *
vm_xrealloc(rb_objspace_t *objspace, void *ptr, size_t size)
{
void *mem;
#if CALC_EXACT_MALLOC_SIZE
size_t oldsize;
#endif
if ((ssize_t)size < 0) {
negative_size_allocation_error("negative re-allocation size");
@ -846,8 +849,8 @@ vm_xrealloc(rb_objspace_t *objspace, void *ptr, size_t size)
#if CALC_EXACT_MALLOC_SIZE
size += sizeof(size_t);
objspace->malloc_params.allocated_size -= size;
ptr = (size_t *)ptr - 1;
oldsize = ((size_t *)ptr)[0];
#endif
mem = realloc(ptr, size);
@ -862,7 +865,7 @@ vm_xrealloc(rb_objspace_t *objspace, void *ptr, size_t size)
malloc_increase += size;
#if CALC_EXACT_MALLOC_SIZE
objspace->malloc_params.allocated_size += size;
objspace->malloc_params.allocated_size += size - oldsize;
((size_t *)mem)[0] = size;
mem = (size_t *)mem + 1;
#endif