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

ruby-changes:24231

From: nobu <ko1@a...>
Date: Tue, 3 Jul 2012 14:37:38 +0900 (JST)
Subject: [ruby-changes:24231] nobu:r36282 (trunk): fix allocated_size

nobu	2012-07-03 14:37:29 +0900 (Tue, 03 Jul 2012)

  New Revision: 36282

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

  Log:
    fix allocated_size
    
    * gc.c (vm_xrealloc): fix allocated_size update, should not ignore old
      size.

  Modified files:
    trunk/gc.c

Index: gc.c
===================================================================
--- gc.c	(revision 36281)
+++ gc.c	(revision 36282)
@@ -832,6 +832,9 @@
 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 @@
 
 #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 @@
     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

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

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