summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authorJean Boussier <byroot@ruby-lang.org>2023-02-15 15:18:01 +0100
committerJean Boussier <jean.boussier@gmail.com>2023-02-16 08:14:44 +0100
commit1a4b4cd7f8b53fc52191c1ddcf3f624a5e687c24 (patch)
tree2143cb0a59d5f680d0c2c245b4698f51f75b952d /vm_method.c
parent1df75d658674d511780e578d3a394e1a9bcee5be (diff)
downloadruby-1a4b4cd7f8b53fc52191c1ddcf3f624a5e687c24.tar.gz
Move `attached_object` into `rb_classext_struct`
Given that signleton classes don't have an allocator, we can re-use these bytes to store the attached object in `rb_classext_struct` without making it larger.
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/vm_method.c b/vm_method.c
index 9af240a2cc..98af316fe6 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1151,7 +1151,10 @@ void
rb_define_alloc_func(VALUE klass, VALUE (*func)(VALUE))
{
Check_Type(klass, T_CLASS);
- RCLASS_ALLOCATOR(klass) = func;
+ if (FL_TEST_RAW(klass, FL_SINGLETON)) {
+ rb_raise(rb_eTypeError, "can't define an allocator for a singleton class");
+ }
+ RCLASS_SET_ALLOCATOR(klass, func);
}
void