Method: Struct#initialize_copy

Defined in:
struct.c

#initialize_copyObject

:nodoc:


# File 'struct.c'

/* :nodoc: */
VALUE
rb_struct_init_copy(VALUE copy, VALUE s)
{
    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");
    }
    if (RSTRUCT_LEN(copy) != RSTRUCT_LEN(s)) {
    rb_raise(rb_eTypeError, "struct size mismatch");
    }
    MEMCPY(RSTRUCT_PTR(copy), RSTRUCT_PTR(s), VALUE, RSTRUCT_LEN(copy));

    return copy;
}