summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-23 07:00:50 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-23 07:00:50 +0000
commit0d8956725284206788bae5fbd6ed032f186ad366 (patch)
tree766be5e92103ecf3001063b0ff5a703f95bfc3b9 /struct.c
parent2109a52503eb61ef38b25aa2266f0313e7ad56ac (diff)
* struct.c (rb_struct_alloc_noinit): new function.
(rb_struct_define_without_accessor): add allocator to the arguments. * range.c (range_alloc): re-introduced using rb_struct_alloc_noinit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/struct.c b/struct.c
index ad5f4619aa..ebf2049b7a 100644
--- a/struct.c
+++ b/struct.c
@@ -218,7 +218,13 @@ make_struct(VALUE name, VALUE members, VALUE klass)
}
VALUE
-rb_struct_define_without_accessor(char *class_name, VALUE super, ...)
+rb_struct_alloc_noinit(VALUE klass)
+{
+ return struct_alloc(klass);
+}
+
+VALUE
+rb_struct_define_without_accessor(char *class_name, VALUE super, rb_alloc_func_t alloc, ...)
{
VALUE klass;
va_list ar;
@@ -247,7 +253,10 @@ rb_struct_define_without_accessor(char *class_name, VALUE super, ...)
rb_iv_set(klass, "__size__", LONG2NUM(RARRAY_LEN(members)));
rb_iv_set(klass, "__members__", members);
- rb_define_alloc_func(klass, struct_alloc);
+ if (alloc)
+ rb_define_alloc_func(klass, alloc);
+ else
+ rb_define_alloc_func(klass, struct_alloc);
return klass;
}