diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-06-25 15:38:28 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-06-25 15:38:28 +0900 |
| commit | 3ceeb0be95874fe867f25004618c31ca8e23ecf4 (patch) | |
| tree | 87bb0c119ce43a09603b1a159da2fa1605106534 /src | |
| parent | d90c5c8e848dbcff500e04eca7c8601409aad0ef (diff) | |
| download | mruby-3ceeb0be95874fe867f25004618c31ca8e23ecf4.tar.gz mruby-3ceeb0be95874fe867f25004618c31ca8e23ecf4.zip | |
add mrb_malloc_simple() that returns NULL on error
Diffstat (limited to 'src')
| -rw-r--r-- | src/gc.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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; |
