mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
cfd9214b3d
When mrb_mt_init_rom() is called on a class that already has a mutable method table (from prior mrb_define_method_id() calls), the mutable top layer is now frozen in place instead of being left as a writable layer that wastes RAM on embedded systems. The frozen bit (bit 29 of alloc field) marks heap-allocated method table layers as temporarily immutable. Unlike the readonly bit (bit 30, for true ROM), frozen layers are automatically unfrozen when methods are later added via mrb_define_method_raw() or removed via mrb_remove_method(). This preserves the c->mt pointer, which is critical because iclasses (from module inclusion) hold a copy of it. Co-authored-by: Claude <noreply@anthropic.com>