diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-21 09:49:05 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-21 09:49:05 +0000 |
commit | 4305eb8e6c0e8ad0db9db29b38510d5815ccaabf (patch) | |
tree | b9148e5be32b80523b96411282236dc1796b0e21 /gc.c | |
parent | bb6607404a993c98d1ede9560b0f34c7551bf0f5 (diff) | |
download | ruby-4305eb8e6c0e8ad0db9db29b38510d5815ccaabf.tar.gz |
gc.c: malloc_usable_size
* gc.c (vm_xrealloc, vm_xfree): use malloc_usable_size() to obtain old
size if available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -5553,6 +5553,10 @@ vm_xrealloc(rb_objspace_t *objspace, void *ptr, size_t new_size, size_t old_size return 0; } +#ifdef HAVE_MALLOC_USABLE_SIZE + old_size = malloc_usable_size(ptr); +#endif + vm_malloc_increase(objspace, new_size, old_size, FALSE); #if CALC_EXACT_MALLOC_SIZE @@ -5587,7 +5591,13 @@ vm_xfree(rb_objspace_t *objspace, void *ptr, size_t old_size) ATOMIC_SIZE_SUB(objspace->malloc_params.allocated_size, cem_oldsize); ATOMIC_SIZE_DEC(objspace->malloc_params.allocations); } +#endif +#ifdef HAVE_MALLOC_USABLE_SIZE + old_size = malloc_usable_size(ptr); +#endif + +#if CALC_EXACT_MALLOC_SIZE if (CALC_EXACT_MALLOC_SIZE_CHECK_OLD_SIZE && old_size > 0 && cem_oldsize - sizeof(size_t) != old_size) { fprintf(stderr, "vm_xfree: old_size mismatch: expected %d, but %d\n", (int)(cem_oldsize-sizeof(size_t)), (int)old_size); } |