diff options
author | John Hawthorn <[email protected]> | 2024-12-11 14:32:43 -0800 |
---|---|---|
committer | John Hawthorn <[email protected]> | 2024-12-11 16:58:35 -0800 |
commit | 36f49eb2b48d855fd168bf5371c9932e35c8029b (patch) | |
tree | 1797a300eaffd2af633153b8cf0aa23962c51db6 | |
parent | 9181e8bc87dd167673bc6cfc255c7003e4c6b05e (diff) |
Fix compilation with MALLOC_ALLOCATED_SIZE
Previously compilation failed with -DMALLOC_ALLOCATED_SIZE=1
Co-authored-by: Matthew Draper <[email protected]>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12313
-rw-r--r-- | gc/default/default.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gc/default/default.c b/gc/default/default.c index aabf48f66c..9f4e9fd6e5 100644 --- a/gc/default/default.c +++ b/gc/default/default.c @@ -8037,9 +8037,9 @@ objspace_malloc_increase_body(rb_objspace_t *objspace, void *mem, size_t new_siz } else { size_t dec_size = old_size - new_size; - size_t allocated_size = objspace->malloc_params.allocated_size; #if MALLOC_ALLOCATED_SIZE_CHECK + size_t allocated_size = objspace->malloc_params.allocated_size; if (allocated_size < dec_size) { rb_bug("objspace_malloc_increase: underflow malloc_params.allocated_size."); } @@ -9286,7 +9286,8 @@ rb_gc_impl_objspace_free(void *objspace_ptr) static VALUE gc_malloc_allocated_size(VALUE self) { - return UINT2NUM(rb_objspace.malloc_params.allocated_size); + rb_objspace_t *objspace = (rb_objspace_t *)rb_gc_get_objspace(); + return ULL2NUM(objspace->malloc_params.allocated_size); } /* @@ -9301,7 +9302,8 @@ gc_malloc_allocated_size(VALUE self) static VALUE gc_malloc_allocations(VALUE self) { - return UINT2NUM(rb_objspace.malloc_params.allocations); + rb_objspace_t *objspace = (rb_objspace_t *)rb_gc_get_objspace(); + return ULL2NUM(objspace->malloc_params.allocations); } #endif |