mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
add mrb_malloc_simple() that returns NULL on error
This commit is contained in:
@@ -182,6 +182,19 @@ mrb_malloc(mrb_state *mrb, size_t len)
|
||||
return mrb_realloc(mrb, 0, len);
|
||||
}
|
||||
|
||||
void*
|
||||
mrb_malloc_simple(mrb_state *mrb, size_t len)
|
||||
{
|
||||
void *p2;
|
||||
|
||||
p2 = (mrb->allocf)(mrb, 0, len, mrb->ud);
|
||||
if (!p2 && len > 0 && mrb->heaps) {
|
||||
mrb_garbage_collect(mrb);
|
||||
p2 = (mrb->allocf)(mrb, 0, len, mrb->ud);
|
||||
}
|
||||
return p2;
|
||||
}
|
||||
|
||||
void*
|
||||
mrb_calloc(mrb_state *mrb, size_t nelem, size_t len)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user