diff options
Diffstat (limited to 'internal/object.h')
| -rw-r--r-- | internal/object.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/internal/object.h b/internal/object.h index 903e2d29a5..99aa1f524b 100644 --- a/internal/object.h +++ b/internal/object.h @@ -11,7 +11,8 @@ #include "ruby/ruby.h" /* for VALUE */ /* object.c */ -size_t rb_obj_embedded_size(uint32_t numiv); + +VALUE rb_class_allocate_instance(VALUE klass); VALUE rb_class_search_ancestor(VALUE klass, VALUE super); NORETURN(void rb_undefined_alloc(VALUE klass)); double rb_num_to_dbl(VALUE val); @@ -59,4 +60,13 @@ RBASIC_SET_CLASS(VALUE obj, VALUE klass) RBASIC_SET_CLASS_RAW(obj, klass); RB_OBJ_WRITTEN(obj, oldv, klass); } + +static inline size_t +rb_obj_embedded_size(uint32_t fields_count) +{ + size_t size = offsetof(struct RObject, as.ary) + (sizeof(VALUE) * fields_count); + // Ensure enough room for the heap pointer if this expands + if (size < sizeof(struct RObject)) size = sizeof(struct RObject); + return size; +} #endif /* INTERNAL_OBJECT_H */ |
