From 4305eb8e6c0e8ad0db9db29b38510d5815ccaabf Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 21 Nov 2013 09:49:05 +0000 Subject: 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 --- gc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gc.c') diff --git a/gc.c b/gc.c index 3c1c63d1d8..c15b19c44f 100644 --- a/gc.c +++ b/gc.c @@ -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); } -- cgit v1.2.3