diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-02-05 14:40:01 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-02-05 14:40:01 +0000 |
commit | ed0fd0279617024a608a8ee4c1aa931db61e92c4 (patch) | |
tree | 81352865082b7b567c9d8185de9bfc40bed82aaf /gc.c | |
parent | 2746f3352b0b6854420529a6432167b4cf03c13f (diff) |
* ruby.h (struct RStruct): embed 3 or less elements structs.
(RSTRUCT_LEN): defined for accessing struct members.
(RSTRUCT_PTR): ditto.
* struct.c: use RSTRUCT_LEN and RSTRUCT_PTR.
(struct_alloc): allocate small structs in embedded format.
(rb_struct_init_copy): ditto.
* gc.c (gc_mark_children): use RSTRUCT_LEN and RSTRUCT_PTR.
(obj_free): ditto.
* marshal.c (w_object): use RSTRUCT_LEN and RSTRUCT_PTR.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -979,8 +979,8 @@ gc_mark_children(VALUE ptr, int lev) case T_STRUCT: { - long len = obj->as.rstruct.len; - VALUE *ptr = obj->as.rstruct.ptr; + long len = RSTRUCT_LEN(obj); + VALUE *ptr = RSTRUCT_PTR(obj); while (len--) { gc_mark(*ptr++, lev); @@ -1234,8 +1234,9 @@ obj_free(VALUE obj) break; case T_STRUCT: - if (RANY(obj)->as.rstruct.ptr) { - RUBY_CRITICAL(free(RANY(obj)->as.rstruct.ptr)); + if (RBASIC(obj)->flags & RSTRUCT_EMBED_LEN_MASK == 0 && + RANY(obj)->as.rstruct.as.heap.ptr) { + RUBY_CRITICAL(free(RANY(obj)->as.rstruct.as.heap.ptr)); } break; |