[前][次][番号順一覧][スレッド一覧]

ruby-changes:31681

From: nobu <ko1@a...>
Date: Thu, 21 Nov 2013 18:49:19 +0900 (JST)
Subject: [ruby-changes:31681] nobu:r43760 (trunk): gc.c: malloc_usable_size

nobu	2013-11-21 18:49:05 +0900 (Thu, 21 Nov 2013)

  New Revision: 43760

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43760

  Log:
    gc.c: malloc_usable_size
    
    * gc.c (vm_xrealloc, vm_xfree): use malloc_usable_size() to obtain old
      size if available.

  Modified files:
    trunk/ChangeLog
    trunk/configure.in
    trunk/gc.c
Index: configure.in
===================================================================
--- configure.in	(revision 43759)
+++ configure.in	(revision 43760)
@@ -1851,6 +1851,7 @@ AC_CHECK_FUNCS(llabs) https://github.com/ruby/ruby/blob/trunk/configure.in#L1851
 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)
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43759)
+++ ChangeLog	(revision 43760)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Nov 21 18:49:02 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* lib/delegate.rb (SimpleDelegator#__getobj__): target object must be set.
Index: gc.c
===================================================================
--- gc.c	(revision 43759)
+++ gc.c	(revision 43760)
@@ -5553,6 +5553,10 @@ vm_xrealloc(rb_objspace_t *objspace, voi https://github.com/ruby/ruby/blob/trunk/gc.c#L5553
 	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 * https://github.com/ruby/ruby/blob/trunk/gc.c#L5591
 	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);
     }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]