From 0bdd529430f8aa91ba4a765b73747b3305357ef3 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 9 May 2025 18:13:28 +0900 Subject: [PATCH] mruby.h: remove allocf and allocf_ud from mrb_state This is preparation for memory allocation restructuring. --- include/mruby.h | 3 --- src/gc.c | 6 +++--- src/state.c | 2 -- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/include/mruby.h b/include/mruby.h index 31bd6e949..da4ba3cc5 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -256,9 +256,6 @@ typedef void (*mrb_atexit_func)(struct mrb_state*); typedef struct mrb_state { struct mrb_jmpbuf *jmp; - mrb_allocf allocf; /* memory allocation function */ - void *allocf_ud; /* auxiliary data of allocf */ - struct mrb_context *c; struct mrb_context *root_c; struct iv_tbl *globals; /* global variable table */ diff --git a/src/gc.c b/src/gc.c index 32fb7027b..e44bfcb9e 100644 --- a/src/gc.c +++ b/src/gc.c @@ -194,10 +194,10 @@ mrb_realloc_simple(mrb_state *mrb, void *p, size_t len) mrb_full_gc(mrb); } #endif - p2 = (mrb->allocf)(mrb, p, len, mrb->allocf_ud); + p2 = mrb_default_allocf(mrb, p, len, NULL); if (!p2 && len > 0 && mrb->gc.heaps && mrb->gc.state != MRB_GC_STATE_SWEEP) { mrb_full_gc(mrb); - p2 = (mrb->allocf)(mrb, p, len, mrb->allocf_ud); + p2 = mrb_default_allocf(mrb, p, len, NULL); } return p2; @@ -256,7 +256,7 @@ mrb_calloc(mrb_state *mrb, size_t nelem, size_t len) MRB_API void mrb_free(mrb_state *mrb, void *p) { - (mrb->allocf)(mrb, p, 0, mrb->allocf_ud); + mrb_default_allocf(mrb, p, 0, NULL); } MRB_API void* diff --git a/src/state.c b/src/state.c index 4ead6d9fa..f28ef046d 100644 --- a/src/state.c +++ b/src/state.c @@ -46,8 +46,6 @@ mrb_open_core(mrb_allocf f, void *ud) if (mrb == NULL) return NULL; *mrb = mrb_state_zero; - mrb->allocf_ud = ud; - mrb->allocf = f; mrb->atexit_stack_len = 0; if (mrb_core_init_protect(mrb, init_gc_and_core, NULL)) {