summaryrefslogtreecommitdiffstats
path: root/struct.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-03 05:20:14 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-03 05:20:14 +0000
commit411216201eb3e8c79b9ae29f42b51b03b3e7b1d8 (patch)
tree324b1dbdf4149be943eb3cbff26ad7f377e53dc0 /struct.c
parent81ba2325bd19cd99c79937cc53a6c19770f62b84 (diff)
downloadruby-411216201eb3e8c79b9ae29f42b51b03b3e7b1d8.tar.gz
ruby-411216201eb3e8c79b9ae29f42b51b03b3e7b1d8.tar.xz
ruby-411216201eb3e8c79b9ae29f42b51b03b3e7b1d8.zip
* variable.c (rb_copy_generic_ivar): remove old generic instance
variable table if it existes. * class.c (rb_make_metaclass): metaclass of a metaclass is a metaclass itself. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/struct.c b/struct.c
index 437819698..324ecc52a 100644
--- a/struct.c
+++ b/struct.c
@@ -421,17 +421,19 @@ rb_struct_to_a(s)
}
static VALUE
-rb_struct_become(clone, s)
- VALUE clone, s;
+rb_struct_become(copy, s)
+ VALUE copy, s;
{
- if (!rb_obj_is_instance_of(s, rb_obj_class(clone))) {
+ if (copy == s) return copy;
+ rb_check_frozen(copy);
+ if (!rb_obj_is_instance_of(s, rb_obj_class(copy))) {
rb_raise(rb_eTypeError, "wrong argument class");
}
- RSTRUCT(clone)->ptr = ALLOC_N(VALUE, RSTRUCT(s)->len);
- RSTRUCT(clone)->len = RSTRUCT(s)->len;
- MEMCPY(RSTRUCT(clone)->ptr, RSTRUCT(s)->ptr, VALUE, RSTRUCT(clone)->len);
+ 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 clone;
+ return copy;
}
static VALUE