summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/struct.c b/struct.c
index 0dd5aba0a0..45797c80a0 100644
--- a/struct.c
+++ b/struct.c
@@ -252,7 +252,7 @@ rb_struct_define(name, va_alist)
ary = rb_ary_new();
va_init_list(ar, name);
- while ((mem = va_arg(ar, char*)) != 0) {
+ while (mem = va_arg(ar, char*)) {
ID slot = rb_intern(mem);
rb_ary_push(ary, ID2SYM(slot));
}
@@ -557,9 +557,8 @@ rb_struct_init_copy(copy, s)
if (!rb_obj_is_instance_of(s, rb_obj_class(copy))) {
rb_raise(rb_eTypeError, "wrong argument class");
}
- if (RSTRUCT(copy)->len != RSTRUCT(s)->len) {
- rb_raise(rb_eTypeError, "struct size mismatch");
- }
+ RSTRUCT(copy)->ptr = ALLOC_N(VALUE, RSTRUCT(s)->len);
+ RSTRUCT(copy)->len = RSTRUCT(s)->len;
MEMCPY(RSTRUCT(copy)->ptr, RSTRUCT(s)->ptr, VALUE, RSTRUCT(copy)->len);
return copy;