* struct.c (rb_struct_new): get rid of too large alloca.
* struct.c (rb_struct_hash): use long. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
53812198da
commit
e2a43c9e09
@ -1,3 +1,9 @@
|
|||||||
|
Wed May 20 19:41:44 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* struct.c (rb_struct_new): get rid of too large alloca.
|
||||||
|
|
||||||
|
* struct.c (rb_struct_hash): use long.
|
||||||
|
|
||||||
Wed May 20 18:58:27 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed May 20 18:58:27 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* vm_eval.c, vm_insnhelper.c: argument number is restricted to
|
* vm_eval.c, vm_insnhelper.c: argument number is restricted to
|
||||||
|
14
struct.c
14
struct.c
@ -129,7 +129,8 @@ static VALUE rb_struct_ref7(VALUE obj) {return RSTRUCT_PTR(obj)[7];}
|
|||||||
static VALUE rb_struct_ref8(VALUE obj) {return RSTRUCT_PTR(obj)[8];}
|
static VALUE rb_struct_ref8(VALUE obj) {return RSTRUCT_PTR(obj)[8];}
|
||||||
static VALUE rb_struct_ref9(VALUE obj) {return RSTRUCT_PTR(obj)[9];}
|
static VALUE rb_struct_ref9(VALUE obj) {return RSTRUCT_PTR(obj)[9];}
|
||||||
|
|
||||||
#define N_REF_FUNC (sizeof(ref_func) / sizeof(ref_func[0]))
|
#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
|
||||||
|
#define N_REF_FUNC numberof(ref_func)
|
||||||
|
|
||||||
static VALUE (*const ref_func[])(VALUE) = {
|
static VALUE (*const ref_func[])(VALUE) = {
|
||||||
rb_struct_ref0,
|
rb_struct_ref0,
|
||||||
@ -342,7 +343,7 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
|
|||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static long
|
||||||
num_members(VALUE klass)
|
num_members(VALUE klass)
|
||||||
{
|
{
|
||||||
VALUE members;
|
VALUE members;
|
||||||
@ -412,12 +413,15 @@ rb_struct_alloc(VALUE klass, VALUE values)
|
|||||||
VALUE
|
VALUE
|
||||||
rb_struct_new(VALUE klass, ...)
|
rb_struct_new(VALUE klass, ...)
|
||||||
{
|
{
|
||||||
VALUE *mem;
|
VALUE tmpargs[N_REF_FUNC], *mem = tmpargs;
|
||||||
long size, i;
|
long size, i;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
size = num_members(klass);
|
size = num_members(klass);
|
||||||
mem = ALLOCA_N(VALUE, size);
|
if (size > numberof(tmpargs)) {
|
||||||
|
tmpargs[0] = rb_ary_tmp_new(size);
|
||||||
|
mem = RARRAY_PTR(tmpargs[0]);
|
||||||
|
}
|
||||||
va_start(args, klass);
|
va_start(args, klass);
|
||||||
for (i=0; i<size; i++) {
|
for (i=0; i<size; i++) {
|
||||||
mem[i] = va_arg(args, VALUE);
|
mem[i] = va_arg(args, VALUE);
|
||||||
@ -809,7 +813,7 @@ static VALUE
|
|||||||
rb_struct_hash(VALUE s)
|
rb_struct_hash(VALUE s)
|
||||||
{
|
{
|
||||||
long i;
|
long i;
|
||||||
unsigned h;
|
unsigned long h;
|
||||||
VALUE n;
|
VALUE n;
|
||||||
|
|
||||||
h = rb_hash_start(rb_hash(rb_obj_class(s)));
|
h = rb_hash_start(rb_hash(rb_obj_class(s)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user