Skip to content

Commit 4aa74b6

Browse files
committed
compile.c: avoid allocating 0 length call_data
if `body->ci_size` is `0`, there's no point allocating 0B, it just wastes an entry in the allocator.
1 parent fab133e commit 4aa74b6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compile.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2596,7 +2596,13 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
25962596
else {
25972597
body->is_entries = NULL;
25982598
}
2599-
body->call_data = ZALLOC_N(struct rb_call_data, body->ci_size);
2599+
2600+
if (body->ci_size) {
2601+
body->call_data = ZALLOC_N(struct rb_call_data, body->ci_size);
2602+
}
2603+
else {
2604+
body->call_data = NULL;
2605+
}
26002606
ISEQ_COMPILE_DATA(iseq)->ci_index = 0;
26012607

26022608
// Calculate the bitmask buffer size.
@@ -13370,6 +13376,11 @@ ibf_load_ci_entries(const struct ibf_load *load,
1337013376
unsigned int ci_size,
1337113377
struct rb_call_data **cd_ptr)
1337213378
{
13379+
if (!ci_size) {
13380+
*cd_ptr = NULL;
13381+
return;
13382+
}
13383+
1337313384
ibf_offset_t reading_pos = ci_entries_offset;
1337413385

1337513386
unsigned int i;

0 commit comments

Comments
 (0)