diff --git a/include/mruby.h b/include/mruby.h index ea750635a..b9dc7a917 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -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. diff --git a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c index 550ebc0c7..a7ab67509 100644 --- a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +++ b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c @@ -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; diff --git a/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c b/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c index 47009ee0c..172ba313f 100644 --- a/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c +++ b/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c @@ -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; diff --git a/mrbgems/mruby-test/mrbgem.rake b/mrbgems/mruby-test/mrbgem.rake index ac78fc811..d8339fec0 100644 --- a/mrbgems/mruby-test/mrbgem.rake +++ b/mrbgems/mruby-test/mrbgem.rake @@ -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);] diff --git a/src/state.c b/src/state.c index 1b92487cf..f94f108be 100644 --- a/src/state.c +++ b/src/state.c @@ -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;