mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
bb6607404a
commit
4305eb8e6c
3 changed files with 16 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Thu Nov 21 18:49:02 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* gc.c (vm_xrealloc, vm_xfree): use malloc_usable_size() to obtain old
|
||||
size if available.
|
||||
|
||||
Thu Nov 21 18:47:29 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/delegate.rb (SimpleDelegator#__getobj__): target object must be set.
|
||||
|
|
|
@ -1851,6 +1851,7 @@ AC_CHECK_FUNCS(llabs)
|
|||
AC_CHECK_FUNCS(lockf)
|
||||
AC_CHECK_FUNCS(log2)
|
||||
AC_CHECK_FUNCS(lstat)
|
||||
AC_CHECK_FUNCS(malloc_usable_size)
|
||||
AC_CHECK_FUNCS(mblen)
|
||||
AC_CHECK_FUNCS(memalign)
|
||||
AC_CHECK_FUNCS(memrchr)
|
||||
|
|
10
gc.c
10
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue