diff options
author | Jean Boussier <[email protected]> | 2025-04-03 16:07:34 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-04-03 16:57:57 +0200 |
commit | 4aa74b605c9960192c30c711fa6e982727eb8d1b (patch) | |
tree | 116153eec31c478adb0b8ca29197383231216873 | |
parent | fab133e629c507f4add4a7dde2e0ba12b7ec281c (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13059
-rw-r--r-- | compile.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -2596,7 +2596,13 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor) else { body->is_entries = NULL; } - body->call_data = ZALLOC_N(struct rb_call_data, body->ci_size); + + if (body->ci_size) { + body->call_data = ZALLOC_N(struct rb_call_data, body->ci_size); + } + else { + body->call_data = NULL; + } ISEQ_COMPILE_DATA(iseq)->ci_index = 0; // Calculate the bitmask buffer size. @@ -13370,6 +13376,11 @@ ibf_load_ci_entries(const struct ibf_load *load, unsigned int ci_size, struct rb_call_data **cd_ptr) { + if (!ci_size) { + *cd_ptr = NULL; + return; + } + ibf_offset_t reading_pos = ci_entries_offset; unsigned int i; |