From 5c71681d82e8bfa002f5d2c92794b2dfac619209 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 9 May 2025 21:53:09 +0900 Subject: [PATCH] allocf.c (mrb_basic_alloc_func): remove ud argument --- include/mruby.h | 4 ++-- src/allocf.c | 5 ++--- src/gc.c | 6 +++--- src/state.c | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/mruby.h b/include/mruby.h index 8f9acbf6a..ea750635a 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -166,7 +166,7 @@ struct mrb_state; * * See mrb_basic_alloc_func in src/allocf.c for the default implementation. */ -typedef void* (*mrb_allocf) (void *ptr, size_t size, void *ud); +typedef void* (*mrb_allocf) (void *ptr, size_t size); #ifndef MRB_FIXED_STATE_ATEXIT_STACK_SIZE #define MRB_FIXED_STATE_ATEXIT_STACK_SIZE 5 @@ -1276,7 +1276,7 @@ MRB_API void mrb_close(mrb_state *mrb); * The memory allocation function. You can redefine this function for your own allocator. * */ -MRB_API void* mrb_basic_alloc_func(void*, size_t, void*); +MRB_API void* mrb_basic_alloc_func(void*, size_t); MRB_API mrb_value mrb_top_self(mrb_state *mrb); diff --git a/src/allocf.c b/src/allocf.c index ae7df7997..2f0971898 100644 --- a/src/allocf.c +++ b/src/allocf.c @@ -6,15 +6,14 @@ #include #include -/* This function serves as the default memory allocation function and accepts four arguments: +/* This function serves as the default memory allocation function and accepts two arguments: * * - `p`: The previous pointer to the memory region. For memory allocation, this parameter is NULL. * - `size`: The new size of the memory region to be returned. - * - `ud`: User data, represented as a `void*`, which is passed to the `mrb_state`. */ void* -mrb_basic_alloc_func(void *p, size_t size, void *ud) +mrb_basic_alloc_func(void *p, size_t size) { if (size == 0) { /* `free(NULL)` should be no-op */ diff --git a/src/gc.c b/src/gc.c index d8f0b5df5..4dd21648d 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_basic_alloc_func(p, len, NULL); + p2 = mrb_basic_alloc_func(p, len); if (!p2 && len > 0 && mrb->gc.heaps && mrb->gc.state != MRB_GC_STATE_SWEEP) { mrb_full_gc(mrb); - p2 = mrb_basic_alloc_func(p, len, NULL); + p2 = mrb_basic_alloc_func(p, len); } 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_basic_alloc_func(p, 0, NULL); + mrb_basic_alloc_func(p, 0); } MRB_API void* diff --git a/src/state.c b/src/state.c index 0a98a6019..1b92487cf 100644 --- a/src/state.c +++ b/src/state.c @@ -42,7 +42,7 @@ mrb_open_core(mrb_allocf f, void *ud) mrb_state *mrb; if (f == NULL) f = mrb_basic_alloc_func; - mrb = (mrb_state*)(f)(NULL, sizeof(mrb_state), ud); + mrb = (mrb_state*)(f)(NULL, sizeof(mrb_state)); if (mrb == NULL) return NULL; *mrb = mrb_state_zero;