1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2015-08-05 17:25:35 +00:00
parent 7918dc352f
commit fb25833690
4 changed files with 39 additions and 16 deletions

View file

@ -1,3 +1,8 @@
Thu Aug 6 02:25:31 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* node.c (rb_alloc_tmp_buffer): use NODE_ALLOCA to mark locations
like as builtin alloca. [ruby-core:70251] [Bug #11418]
Wed Aug 5 14:37:55 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* transcode.c (rb_econv_open0): rb_econv_t::source_encoding_name

24
node.c
View file

@ -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);
}
}

View file

@ -1116,22 +1116,6 @@ rb_str_tmp_new(long len)
return str_new(0, 0, len);
}
void *
rb_alloc_tmp_buffer(volatile VALUE *store, long len)
{
VALUE s = rb_str_tmp_new(len);
*store = s;
return RSTRING_PTR(s);
}
void
rb_free_tmp_buffer(volatile VALUE *store)
{
VALUE s = *store;
*store = 0;
if (s) rb_str_clear(s);
}
void
rb_str_free(VALUE str)
{

View file

@ -2172,4 +2172,14 @@ EOS
w.close if w
r.close if r
end if defined?(fork)
def test_many_args
bug11418 = '[ruby-core:70251] [Bug #11418]'
assert_in_out_err([], <<-"end;", ["x"]*256, [], bug11418)
bin = "#{EnvUtil.rubybin}"
args = Array.new(256) {"x"}
GC.stress = true
system(bin, "--disable=gems", "-w", "-e", "puts ARGV", *args)
end;
end
end