* array.c (rb_ary_tmp_new): added.

This function creates internal use only array (which is completely
  hided by ObjectSpace.each_object) with filling nil.
  Otherwise, it can be incldues strange VALUEs.
* internal.h: added.
* node.h: use rb_ary_tmp_new_fill() for MEMO.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2014-08-15 10:32:58 +00:00
Родитель 85691b9578
Коммит b5e89e44f1
4 изменённых файлов: 23 добавлений и 3 удалений

Просмотреть файл

@ -1,3 +1,15 @@
Fri Aug 15 19:27:25 2014 Koichi Sasada <ko1@atdot.net>
* array.c (rb_ary_tmp_new): added.
This function creates internal use only array (which is completely
hided by ObjectSpace.each_object) with filling nil.
Otherwise, it can be incldues strange VALUEs.
* internal.h: added.
* node.h: use rb_ary_tmp_new_fill() for MEMO.
Fri Aug 15 10:13:37 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com> Fri Aug 15 10:13:37 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* lib/gserver.rb: removed unmaintained code. * lib/gserver.rb: removed unmaintained code.

Просмотреть файл

@ -550,6 +550,15 @@ rb_ary_tmp_new(long capa)
return ary_new(0, capa); return ary_new(0, capa);
} }
VALUE
rb_ary_tmp_new_fill(long capa)
{
VALUE ary = ary_new(0, capa);
ary_memfill(ary, 0, capa, Qnil);
ARY_SET_LEN(ary, capa);
return ary;
}
void void
rb_ary_free(VALUE ary) rb_ary_free(VALUE ary)
{ {

Просмотреть файл

@ -506,6 +506,7 @@ struct vtm; /* defined by timev.h */
VALUE rb_ary_last(int, const VALUE *, VALUE); VALUE rb_ary_last(int, const VALUE *, VALUE);
void rb_ary_set_len(VALUE, long); void rb_ary_set_len(VALUE, long);
void rb_ary_delete_same(VALUE, VALUE); void rb_ary_delete_same(VALUE, VALUE);
VALUE rb_ary_tmp_new_fill(long capa);
/* bignum.c */ /* bignum.c */
VALUE rb_big_fdiv(VALUE x, VALUE y); VALUE rb_big_fdiv(VALUE x, VALUE y);

4
node.h
Просмотреть файл

@ -468,9 +468,7 @@ typedef struct RNode {
#define roomof(x, y) ((sizeof(x) + sizeof(y) - 1) / sizeof(y)) #define roomof(x, y) ((sizeof(x) + sizeof(y) - 1) / sizeof(y))
#define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value)) #define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
#define NEW_MEMO_FOR(type, value) \ #define NEW_MEMO_FOR(type, value) \
(rb_ary_set_len(((value) = rb_ary_tmp_new(roomof(type, VALUE))), \ ((value) = rb_ary_tmp_new_fill(roomof(type, VALUE)), MEMO_FOR(type, value))
roomof(type, VALUE)), \
MEMO_FOR(type, value))
RUBY_SYMBOL_EXPORT_BEGIN RUBY_SYMBOL_EXPORT_BEGIN