diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2026-01-30 17:00:23 +0100 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2026-01-31 10:35:48 +0100 |
| commit | 0584f9fb0951bee3ea2645bdba0af56a2b320ed3 (patch) | |
| tree | f6c4e23d3b465fcaf79ac98c00eecdf47572bbbe | |
| parent | 050c00141c7e8fdded5355b4c31e971ae21403d0 (diff) | |
gc.c: Replace ruby_xfree by ruby_sized_xfree when applicable
| -rw-r--r-- | bignum.c | 2 | ||||
| -rw-r--r-- | gc.c | 14 |
2 files changed, 8 insertions, 8 deletions
@@ -3048,7 +3048,7 @@ rb_big_realloc(VALUE big, size_t len) if (BIGNUM_LEN(big) == 0) { RBIGNUM(big)->as.heap.digits = ALLOC_N(BDIGIT, len); } - else if (BIGNUM_LEN(big) < len) { + else if (BIGNUM_LEN(big) != len) { REALLOC_N(RBIGNUM(big)->as.heap.digits, BDIGIT, len); } } @@ -1455,7 +1455,7 @@ rb_gc_obj_free(void *objspace, VALUE obj) st_free_table(ROBJECT_FIELDS_HASH(obj)); } else { - xfree(ROBJECT(obj)->as.heap.fields); + SIZED_FREE_N(ROBJECT(obj)->as.heap.fields, ROBJECT_FIELDS_CAPACITY(obj)); RB_DEBUG_COUNTER_INC(obj_obj_ptr); } } @@ -1550,7 +1550,7 @@ rb_gc_obj_free(void *objspace, VALUE obj) } #endif onig_region_free(&rm->regs, 0); - xfree(rm->char_offset); + SIZED_FREE_N(rm->char_offset, rm->char_offset_num_allocated); RB_DEBUG_COUNTER_INC(obj_match_ptr); } @@ -1587,7 +1587,7 @@ rb_gc_obj_free(void *objspace, VALUE obj) case T_BIGNUM: if (!BIGNUM_EMBED_P(obj) && BIGNUM_DIGITS(obj)) { - xfree(BIGNUM_DIGITS(obj)); + SIZED_FREE_N(BIGNUM_DIGITS(obj), BIGNUM_LEN(obj)); RB_DEBUG_COUNTER_INC(obj_bignum_ptr); } else { @@ -1605,7 +1605,7 @@ rb_gc_obj_free(void *objspace, VALUE obj) RB_DEBUG_COUNTER_INC(obj_struct_embed); } else { - xfree((void *)RSTRUCT(obj)->as.heap.ptr); + SIZED_FREE_N(RSTRUCT(obj)->as.heap.ptr, RSTRUCT(obj)->as.heap.len); RB_DEBUG_COUNTER_INC(obj_struct_ptr); } break; @@ -3657,7 +3657,7 @@ rb_gc_unregister_address(VALUE *addr) if (tmp->varptr == addr) { vm->global_object_list = tmp->next; - xfree(tmp); + SIZED_FREE(tmp); return; } while (tmp->next) { @@ -3665,7 +3665,7 @@ rb_gc_unregister_address(VALUE *addr) struct global_object_list *t = tmp->next; tmp->next = tmp->next->next; - xfree(t); + SIZED_FREE(t); break; } tmp = tmp->next; @@ -3780,8 +3780,8 @@ gc_ref_update_object(void *objspace, VALUE v) if (slot_size >= embed_size) { // Object can be re-embedded memcpy(ROBJECT(v)->as.ary, ptr, sizeof(VALUE) * ROBJECT_FIELDS_COUNT(v)); + SIZED_FREE_N(ptr, ROBJECT_FIELDS_CAPACITY(v)); FL_UNSET_RAW(v, ROBJECT_HEAP); - xfree(ptr); ptr = ROBJECT(v)->as.ary; } } |
