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

ruby-changes:39419

From: nobu <ko1@a...>
Date: Thu, 6 Aug 2015 10:56:42 +0900 (JST)
Subject: [ruby-changes:39419] nobu:r51500 (trunk): gc.c: move tmp buffer functions

nobu	2015-08-06 10:56:37 +0900 (Thu, 06 Aug 2015)

  New Revision: 51500

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

  Log:
    gc.c: move tmp buffer functions
    
    * gc.c (rb_alloc_tmp_buffer, rb_free_tmp_buffer): move from
      node.c.

  Modified files:
    trunk/gc.c
    trunk/node.c
Index: gc.c
===================================================================
--- gc.c	(revision 51499)
+++ gc.c	(revision 51500)
@@ -7766,6 +7766,36 @@ ruby_mimfree(void *ptr) https://github.com/ruby/ruby/blob/trunk/gc.c#L7766
     free(mem);
 }
 
+void *
+rb_alloc_tmp_buffer(volatile VALUE *store, long len)
+{
+    NODE *s;
+    long cnt;
+    void *ptr;
+
+    if (len < 0 || (cnt = (long)roomof(len, sizeof(VALUE))) < 0) {
+	rb_raise(rb_eArgError, "negative buffer size (or size too big)");
+    }
+
+    s = rb_node_newnode(NODE_ALLOCA, 0, 0, 0);
+    ptr = ruby_xmalloc(cnt * sizeof(VALUE));
+    s->u1.value = (VALUE)ptr;
+    s->u3.cnt = cnt;
+    *store = (VALUE)s;
+    return ptr;
+}
+
+void
+rb_free_tmp_buffer(volatile VALUE *store)
+{
+    VALUE s = ATOMIC_VALUE_EXCHANGE(*store, 0);
+    if (s) {
+	void *ptr = ATOMIC_PTR_EXCHANGE(RNODE(s)->u1.node, 0);
+	RNODE(s)->u3.cnt = 0;
+	ruby_xfree(ptr);
+    }
+}
+
 #if MALLOC_ALLOCATED_SIZE
 /*
  *  call-seq:
Index: node.c
===================================================================
--- node.c	(revision 51499)
+++ node.c	(revision 51500)
@@ -1075,33 +1075,3 @@ rb_gc_mark_node(NODE *obj) https://github.com/ruby/ruby/blob/trunk/node.c#L1075
     }
     return 0;
 }
-
-void *
-rb_alloc_tmp_buffer(volatile VALUE *store, long len)
-{
-    NODE *s;
-    long cnt;
-    void *ptr;
-
-    if (len < 0 || (cnt = (long)roomof(len, sizeof(VALUE))) < 0) {
-	rb_raise(rb_eArgError, "negative buffer size (or size too big)");
-    }
-
-    s = rb_node_newnode(NODE_ALLOCA, 0, 0, 0);
-    ptr = xmalloc(cnt * sizeof(VALUE));
-    s->u1.value = (VALUE)ptr;
-    s->u3.cnt = cnt;
-    *store = (VALUE)s;
-    return ptr;
-}
-
-void
-rb_free_tmp_buffer(volatile VALUE *store)
-{
-    VALUE s = ATOMIC_VALUE_EXCHANGE(*store, 0);
-    if (s) {
-	void *ptr = ATOMIC_PTR_EXCHANGE(RNODE(s)->u1.node, 0);
-	RNODE(s)->u3.cnt = 0;
-	xfree(ptr);
-    }
-}

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

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