aboutsummaryrefslogtreecommitdiffstats
path: root/node.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-05 17:25:35 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-05 17:25:35 +0000
commitd4bac78163f2ed33737b1ec97de9ae10e52b812d (patch)
tree5675f800cf21be22a937deb1c1c1ef2bd6fc94db /node.c
parent8a3ec4824f9ad802d29a5631fd2e9b10a6cf7c02 (diff)
downloadruby-d4bac78163f2ed33737b1ec97de9ae10e52b812d.tar.gz
node.c: NODE_ALLOCA for ALLOCV
* node.c (rb_alloc_tmp_buffer): use NODE_ALLOCA to mark locations like as builtin alloca. [ruby-core:70251] [Bug #11418] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'node.c')
-rw-r--r--node.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/node.c b/node.c
index 79f65ec684..7551a811c8 100644
--- a/node.c
+++ b/node.c
@@ -1075,3 +1075,27 @@ rb_gc_mark_node(NODE *obj)
}
return 0;
}
+
+void *
+rb_alloc_tmp_buffer(volatile VALUE *store, long len)
+{
+ NODE *s = rb_node_newnode(NODE_ALLOCA, 0, 0, 0);
+ void *ptr = xmalloc(len);
+ s->u1.node = ptr;
+ s->u3.cnt = len / sizeof(VALUE);
+ *store = (VALUE)s;
+ return ptr;
+}
+
+void
+rb_free_tmp_buffer(volatile VALUE *store)
+{
+ VALUE s = *store;
+ *store = 0;
+ if (s) {
+ void *ptr = RNODE(s)->u1.node;
+ RNODE(s)->u1.node = 0;
+ RNODE(s)->u3.cnt = 0;
+ xfree(ptr);
+ }
+}