gc.c: rename mrb_alloca() to mrb_temp_alloc() and fix memory leaks

rename mrb_alloca() to mrb_temp_alloc() for clearer naming - the new name
better describes its purpose as GC-managed temporary allocation. keep
mrb_alloca() as a macro alias for backward compatibility.

apply mrb_temp_alloc() to fix potential memory leaks in:
- mruby-strftime: if mrb_str_cat() raises, allocated buffers now cleaned by GC
- mruby-io File.readlink: if mrb_str_new() raises, buffer now cleaned by GC

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-01-08 08:22:15 +09:00
parent c9e3af60e1
commit 7fe5c2e260
4 changed files with 16 additions and 38 deletions
+1 -1
View File
@@ -266,7 +266,7 @@ mrb_free(mrb_state *mrb, void *p)
}
MRB_API void*
mrb_alloca(mrb_state *mrb, size_t size)
mrb_temp_alloc(mrb_state *mrb, size_t size)
{
struct RString *s;
s = MRB_OBJ_ALLOC(mrb, MRB_TT_STRING, NULL);