mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
allocf.c (mrb_basic_alloc_func): remove ud argument
This commit is contained in:
+2
-2
@@ -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);
|
||||
|
||||
|
||||
+2
-3
@@ -6,15 +6,14 @@
|
||||
#include <stdlib.h>
|
||||
#include <mruby.h>
|
||||
|
||||
/* 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 */
|
||||
|
||||
@@ -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*
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user