summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-06-25 15:38:28 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2013-06-25 15:38:28 +0900
commit3ceeb0be95874fe867f25004618c31ca8e23ecf4 (patch)
tree87bb0c119ce43a09603b1a159da2fa1605106534 /src
parentd90c5c8e848dbcff500e04eca7c8601409aad0ef (diff)
downloadmruby-3ceeb0be95874fe867f25004618c31ca8e23ecf4.tar.gz
mruby-3ceeb0be95874fe867f25004618c31ca8e23ecf4.zip
add mrb_malloc_simple() that returns NULL on error
Diffstat (limited to 'src')
-rw-r--r--src/gc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gc.c b/src/gc.c
index 3e33c052c..7eee61dc1 100644
--- a/src/gc.c
+++ b/src/gc.c
@@ -183,6 +183,19 @@ mrb_malloc(mrb_state *mrb, size_t 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)
{
void *p;