summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-06 01:56:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-06 01:56:37 +0000
commit95c84eac49064986bfd877ccf4d7e91e9929e833 (patch)
tree90ceb969840381ae0fdf3bf16eabd9b5b0cc879b
parent8b6a0f732597e2edd274d5634b464a344821ee9b (diff)
gc.c: move tmp buffer functions
* gc.c (rb_alloc_tmp_buffer, rb_free_tmp_buffer): move from node.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--gc.c30
-rw-r--r--node.c30
2 files changed, 30 insertions, 30 deletions
diff --git a/gc.c b/gc.c
index 1c0eaad8d2..a3af6fefbb 100644
--- a/gc.c
+++ b/gc.c
@@ -7766,6 +7766,36 @@ ruby_mimfree(void *ptr)
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:
diff --git a/node.c b/node.c
index 022f5e0925..79f65ec684 100644
--- a/node.c
+++ b/node.c
@@ -1075,33 +1075,3 @@ rb_gc_mark_node(NODE *obj)
}
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);
- }
-}