Add `mrbc_cleanup_local_variables()` with `mrbc_context`; ref
Clean up defined local variables.
MODIFY
include/mruby/compile.h
include/mruby/compile.h
@@ -42,6 +42,7 @@ MRB_API mrbc_context* mrbc_context_new(mrb_state *mrb);
MRB_API void mrbc_context_free(mrb_state *mrb, mrbc_context *cxt);
MRB_API const char *mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s);
MRB_API void mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*partial_hook)(struct mrb_parser_state*), void*data);
+MRB_API void mrbc_cleanup_local_variables(mrb_state *mrb, mrbc_context *c);
/* AST node structure */
typedef struct mrb_ast_node {

MODIFY
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
@@ -6302,6 +6302,16 @@ mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*func)(struct mrb_parser
c->partial_data = data;
}
+MRB_API void
+mrbc_cleanup_local_variables(mrb_state *mrb, mrbc_context *c)
+{
+ if (c->syms) {
+ mrb_free(mrb, c->syms);
+ c->syms = NULL;
+ c->slen = 0;
+ }
+}
+
MRB_API void
mrb_parser_set_filename(struct mrb_parser_state *p, const char *f)
{

Add `mrbc_cleanup_local_variables()` with `mrbc_context`; ref #4931

Clean up defined local variables.