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

ruby-changes:6760

From: nobu <ko1@a...>
Date: Thu, 31 Jul 2008 01:12:14 +0900 (JST)
Subject: [ruby-changes:6760] Ruby:r18276 (mvm): * thread.c (ruby_vm_specific_ptr): fix for reallocation.

nobu	2008-07-31 01:12:01 +0900 (Thu, 31 Jul 2008)

  New Revision: 18276

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

  Log:
    * thread.c (ruby_vm_specific_ptr): fix for reallocation.

  Modified files:
    branches/mvm/ChangeLog
    branches/mvm/thread.c

Index: mvm/ChangeLog
===================================================================
--- mvm/ChangeLog	(revision 18275)
+++ mvm/ChangeLog	(revision 18276)
@@ -1,3 +1,7 @@
+Thu Jul 31 01:11:58 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread.c (ruby_vm_specific_ptr): fix for reallocation.
+
 Thu Jul 31 00:58:33 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* pack.c (pack_unpack): reduced static variables.
Index: mvm/thread.c
===================================================================
--- mvm/thread.c	(revision 18275)
+++ mvm/thread.c	(revision 18276)
@@ -3700,7 +3700,7 @@
     int last;
 } specific_key = {
     RB_THREAD_LOCK_INITIALIZER,
-    ruby_builtin_object_count + 8,
+    (ruby_builtin_object_count + 8) & ~7,
 };
 
 int
@@ -3723,13 +3723,16 @@
 ruby_vm_specific_ptr(rb_vm_t *vm, int key)
 {
     VALUE *ptr;
+    long len;
 
     ptr = vm->specific_storage.ptr;
-    if (!ptr || vm->specific_storage.len <= key) {
-	ptr = realloc(vm->specific_storage.ptr, sizeof(VALUE) * (key + 1));
+    len = vm->specific_storage.len;
+    if (!ptr || len <= key) {
+	long newlen = (key + 8) & ~7;
+	ptr = realloc(ptr, sizeof(VALUE) * newlen);
 	vm->specific_storage.ptr = ptr;
-	MEMZERO(ptr, VALUE, key + 1 - vm->specific_storage.len);
-	vm->specific_storage.len = key + 1;
+	vm->specific_storage.len = newlen;
+	MEMZERO(ptr + len, VALUE, newlen - len);
     }
     return &ptr[key];
 }

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

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