diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-03 05:37:29 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-03 05:37:29 +0000 |
commit | c7c397f91757d2b1bcc9c21594bc1494750bc7cb (patch) | |
tree | d353c027011c94ff872dc9c2ee8d1a50991f3171 /gc.c | |
parent | 1f233501941fac4c546f6ab0a1945d2eeb56df43 (diff) | |
download | ruby-c7c397f91757d2b1bcc9c21594bc1494750bc7cb.tar.gz |
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
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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 |