From 66bd6ffcbcc2147b2696087266f4f6db8b38cce9 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Fri, 19 Jan 2018 07:16:54 +0000 Subject: [PATCH] svn merge -c -61947 . Previous commit fails in CI. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/array.c b/array.c index dab0776297..5bc69f6899 100644 --- a/array.c +++ b/array.c @@ -5064,6 +5064,8 @@ rb_ary_cycle(int argc, VALUE *argv, VALUE ary) return Qnil; } +#define tmpbuf(n, size) rb_str_tmp_new((n)*(size)) +#define tmpbuf_discard(s) (rb_str_resize((s), 0L), RBASIC_SET_CLASS_RAW(s, rb_cString)) #define tmpary(n) rb_ary_tmp_new(n) #define tmpary_discard(a) (ary_discard(a), RBASIC_SET_CLASS_RAW(a, rb_cArray)) @@ -5566,9 +5568,9 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary) { int n = argc+1; /* How many arrays we're operating on */ volatile VALUE t0 = tmpary(n); - volatile VALUE t1 = Qundef; + volatile VALUE t1 = tmpbuf(n, sizeof(int)); VALUE *arrays = RARRAY_PTR(t0); /* The arrays we're computing the product of */ - int *counters = ALLOCV_N(int, t1, n); /* The current position in each one */ + int *counters = (int*)RSTRING_PTR(t1); /* The current position in each one */ VALUE result = Qnil; /* The array we'll be returning, when no block given */ long i,j; long resultlen = 1; @@ -5645,7 +5647,7 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary) } done: tmpary_discard(t0); - ALLOCV_END(t1); + tmpbuf_discard(t1); return NIL_P(result) ? ary : result; }