diff options
author | Peter Zhu <[email protected]> | 2021-08-02 14:22:47 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2021-10-25 13:26:23 -0400 |
commit | 6374be5a8188ff5ed2c70b9f1d76672c87a0eda7 (patch) | |
tree | 6ac8436f9e29bede5bf7ad167625c47082e5291e /class.c | |
parent | 46b66eb9e8e6de2d5750591e532310e8f8599d90 (diff) |
[Feature #18239] Refactor RVARGC alloc functions
The allocation functions no longer assume that one RVALUE needs to be
allocated.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4933
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -167,16 +167,16 @@ rb_class_detach_module_subclasses(VALUE klass) static VALUE class_alloc(VALUE flags, VALUE klass) { - size_t payload_size = 0; + size_t alloc_size = sizeof(struct RClass); #if USE_RVARGC - payload_size = sizeof(rb_classext_t); + alloc_size += sizeof(rb_classext_t); #endif - RVARGC_NEWOBJ_OF(obj, struct RClass, klass, (flags & T_MASK) | FL_PROMOTED1 /* start from age == 2 */ | (RGENGC_WB_PROTECTED_CLASS ? FL_WB_PROTECTED : 0), payload_size); + RVARGC_NEWOBJ_OF(obj, struct RClass, klass, (flags & T_MASK) | FL_PROMOTED1 /* start from age == 2 */ | (RGENGC_WB_PROTECTED_CLASS ? FL_WB_PROTECTED : 0), alloc_size); #if USE_RVARGC - obj->ptr = (rb_classext_t *)rb_gc_rvargc_object_data((VALUE)obj); + obj->ptr = (rb_classext_t *)((char *)obj + sizeof(struct RClass)); #else obj->ptr = ZALLOC(rb_classext_t); #endif |