mruby.h: remove mrb_allocf type

As a result, we removed (already obsoleted) `mrb_open_allocf()', and
made `mrb_open_core()` take no argument. [incompatible changes]
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-05-10 07:38:04 +09:00
parent 5c71681d82
commit 5522c94bb3
5 changed files with 8 additions and 41 deletions
+1 -25
View File
@@ -157,17 +157,6 @@ typedef uint32_t mrb_aspec;
typedef struct mrb_irep mrb_irep;
struct mrb_state;
/**
* Function pointer type of custom allocator used in @see mrb_open_allocf.
*
* The function pointing it must behave similarly as realloc except:
* - If ptr is NULL it must allocate new space.
* - If size is zero, ptr must be freed.
*
* See mrb_basic_alloc_func in src/allocf.c for the default implementation.
*/
typedef void* (*mrb_allocf) (void *ptr, size_t size);
#ifndef MRB_FIXED_STATE_ATEXIT_STACK_SIZE
#define MRB_FIXED_STATE_ATEXIT_STACK_SIZE 5
#endif
@@ -1237,19 +1226,6 @@ MRB_API char* mrb_locale_from_utf8(const char *p, int len);
*/
MRB_API mrb_state* mrb_open(void);
/**
* Create new mrb_state with custom allocators.
*
* @param f
* Reference to the allocation function.
* @param ud
* User data will be passed to custom allocator f.
* If user data isn't required just pass NULL.
* @return
* Pointer to the newly created mrb_state.
*/
MRB_API mrb_state* mrb_open_allocf(mrb_allocf f, void *ud);
/**
* Create new mrb_state with just the mruby core
*
@@ -1262,7 +1238,7 @@ MRB_API mrb_state* mrb_open_allocf(mrb_allocf f, void *ud);
* @return
* Pointer to the newly created mrb_state.
*/
MRB_API mrb_state* mrb_open_core(mrb_allocf f, void *ud);
MRB_API mrb_state* mrb_open_core(void);
/**
* Closes and frees a mrb_state.
+1 -1
View File
@@ -286,7 +286,7 @@ dump_file(mrb_state *mrb, FILE *wfp, const char *outfile, const struct RProc *pr
int
main(int argc, char **argv)
{
mrb_state *mrb = mrb_open_core(NULL, NULL);
mrb_state *mrb = mrb_open_core();
int n, result;
struct mrbc_args args;
FILE *wfp;
@@ -126,7 +126,7 @@ main(int argc, char **argv)
print_usage(argv[0]);
return EXIT_FAILURE;
}
mrb = mrb_open_core(mrb_basic_alloc_func, NULL);
mrb = mrb_open_core();
if (mrb == NULL) {
fputs("Invalid mrb_state, exiting mruby-strip\n", stderr);
return EXIT_FAILURE;
+1 -1
View File
@@ -69,7 +69,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
unless g.test_args.empty?
f.puts %Q[ mrb_value test_args_hash;]
end
f.puts %Q[ mrb_state *mrb2 = mrb_open_core(mrb_basic_alloc_func, NULL);]
f.puts %Q[ mrb_state *mrb2 = mrb_open_core();]
f.puts %Q[ if (mrb2 == NULL) {]
f.puts %Q[ fprintf(stderr, "Invalid mrb_state, exiting \%s", __func__);]
f.puts %Q[ exit(EXIT_FAILURE);]
+4 -13
View File
@@ -36,13 +36,12 @@ init_gc_and_core(mrb_state *mrb, void *opaque)
}
MRB_API mrb_state*
mrb_open_core(mrb_allocf f, void *ud)
mrb_open_core(void)
{
static const mrb_state mrb_state_zero = { 0 };
mrb_state *mrb;
if (f == NULL) f = mrb_basic_alloc_func;
mrb = (mrb_state*)(f)(NULL, sizeof(mrb_state));
mrb = (mrb_state*)mrb_basic_alloc_func(NULL, sizeof(mrb_state));
if (mrb == NULL) return NULL;
*mrb = mrb_state_zero;
@@ -56,14 +55,6 @@ mrb_open_core(mrb_allocf f, void *ud)
return mrb;
}
MRB_API mrb_state*
mrb_open(void)
{
mrb_state *mrb = mrb_open_allocf(mrb_basic_alloc_func, NULL);
return mrb;
}
#ifndef MRB_NO_GEMS
static void
init_mrbgems(mrb_state *mrb, void *opaque)
@@ -73,9 +64,9 @@ init_mrbgems(mrb_state *mrb, void *opaque)
#endif
MRB_API mrb_state*
mrb_open_allocf(mrb_allocf f, void *ud)
mrb_open(void)
{
mrb_state *mrb = mrb_open_core(f, ud);
mrb_state *mrb = mrb_open_core();
if (mrb == NULL) {
return NULL;