diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-05-28 10:44:18 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-05-29 11:47:12 +0900 |
| commit | 2b81ea7ec1c7645b13b097e5b249cbc99f374da7 (patch) | |
| tree | 94ed8b8da63e535477da932ddc05da67f137408a /src | |
| parent | a1e1af44d205c2c29608f508cce84d6b6ebd2bbf (diff) | |
| download | mruby-2b81ea7ec1c7645b13b097e5b249cbc99f374da7.tar.gz mruby-2b81ea7ec1c7645b13b097e5b249cbc99f374da7.zip | |
Add `mrb_alloca` again; ref #4470
This time, the allocated memory comes from the string object, which is
referenced from GC arena. The memory region will be reclaimed when the C
function called from VM is terminated, or the GC arena is restored.
Diffstat (limited to 'src')
| -rw-r--r-- | src/gc.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -277,6 +277,13 @@ mrb_free(mrb_state *mrb, void *p) (mrb->allocf)(mrb, p, 0, mrb->allocf_ud); } +MRB_API void* +mrb_alloca(mrb_state *mrb, size_t size) +{ + mrb_value str = mrb_str_new(mrb, NULL, size); + return RSTRING_PTR(str); +} + static mrb_bool heap_p(mrb_gc *gc, struct RBasic *object) { |
