summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2026-02-01 21:19:10 +0100
committerJean Boussier <jean.boussier@gmail.com>2026-02-01 21:57:59 +0100
commit4e196af17c334de1eb74f7bb036fec12a35b794e (patch)
tree65335f9d7441487bd1bc4846fdb4f1c4f44c775b
parenta93604b5ed813c43aca572ad64c1a7b66b715429 (diff)
Use ruby_sized_xfree
-rw-r--r--box.c2
-rw-r--r--marshal.c2
-rw-r--r--re.c4
-rw-r--r--scheduler.c19
-rw-r--r--variable.c2
5 files changed, 8 insertions, 21 deletions
diff --git a/box.c b/box.c
index 830172cdd5..bfb6f51346 100644
--- a/box.c
+++ b/box.c
@@ -271,7 +271,7 @@ box_entry_free(void *ptr)
cleanup_all_local_extensions(box->ruby_dln_libmap);
box_root_free(ptr);
- xfree(ptr);
+ SIZED_FREE(box);
}
static size_t
diff --git a/marshal.c b/marshal.c
index 1a9e817872..e2a0ce6dd1 100644
--- a/marshal.c
+++ b/marshal.c
@@ -2350,7 +2350,7 @@ r_object(struct load_arg *arg)
static void
clear_load_arg(struct load_arg *arg)
{
- xfree(arg->buf);
+ ruby_sized_xfree(arg->buf, BUFSIZ);
arg->buf = NULL;
arg->buflen = 0;
arg->offset = 0;
diff --git a/re.c b/re.c
index 82e9407a0a..0e169694d4 100644
--- a/re.c
+++ b/re.c
@@ -1023,7 +1023,7 @@ update_char_offset(VALUE match)
num_regs = rm->regs.num_regs;
if (rm->char_offset_num_allocated < num_regs) {
- REALLOC_N(rm->char_offset, struct rmatch_offset, num_regs);
+ SIZED_REALLOC_N(rm->char_offset, struct rmatch_offset, num_regs, rm->char_offset_num_allocated);
rm->char_offset_num_allocated = num_regs;
}
@@ -1101,7 +1101,7 @@ match_init_copy(VALUE obj, VALUE orig)
if (RMATCH_EXT(orig)->char_offset_num_allocated) {
if (rm->char_offset_num_allocated < rm->regs.num_regs) {
- REALLOC_N(rm->char_offset, struct rmatch_offset, rm->regs.num_regs);
+ SIZED_REALLOC_N(rm->char_offset, struct rmatch_offset, rm->regs.num_regs, rm->char_offset_num_allocated);
rm->char_offset_num_allocated = rm->regs.num_regs;
}
MEMCPY(rm->char_offset, RMATCH_EXT(orig)->char_offset,
diff --git a/scheduler.c b/scheduler.c
index b23ddad41e..c2f370a22a 100644
--- a/scheduler.c
+++ b/scheduler.c
@@ -77,19 +77,6 @@ struct rb_fiber_scheduler_blocking_operation {
volatile rb_atomic_t status;
};
-static void
-blocking_operation_mark(void *ptr)
-{
- // No Ruby objects to mark in our struct
-}
-
-static void
-blocking_operation_free(void *ptr)
-{
- rb_fiber_scheduler_blocking_operation_t *blocking_operation = (rb_fiber_scheduler_blocking_operation_t *)ptr;
- ruby_xfree(blocking_operation);
-}
-
static size_t
blocking_operation_memsize(const void *ptr)
{
@@ -99,11 +86,11 @@ blocking_operation_memsize(const void *ptr)
static const rb_data_type_t blocking_operation_data_type = {
"Fiber::Scheduler::BlockingOperation",
{
- blocking_operation_mark,
- blocking_operation_free,
+ NULL, // nothing to mark
+ RUBY_DEFAULT_FREE,
blocking_operation_memsize,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
/*
diff --git a/variable.c b/variable.c
index ce1873560f..dfd1dfc3c4 100644
--- a/variable.c
+++ b/variable.c
@@ -1890,7 +1890,7 @@ rb_ensure_iv_list_size(VALUE obj, uint32_t current_len, uint32_t new_capacity)
RUBY_ASSERT(!rb_shape_obj_too_complex_p(obj));
if (FL_TEST_RAW(obj, ROBJECT_HEAP)) {
- REALLOC_N(ROBJECT(obj)->as.heap.fields, VALUE, new_capacity);
+ SIZED_REALLOC_N(ROBJECT(obj)->as.heap.fields, VALUE, new_capacity, current_len);
}
else {
VALUE *ptr = ROBJECT_FIELDS(obj);