summaryrefslogtreecommitdiffhomepage
path: root/src/state.c
diff options
context:
space:
mode:
authordearblue <[email protected]>2019-05-25 23:59:43 +0900
committerdearblue <[email protected]>2019-05-25 23:59:43 +0900
commitd1e1bb0d5b45d9f1c5de943a036c86542698af49 (patch)
treeba2b910a5c651698d3587875a6cffe84ef056972 /src/state.c
parentf455cb6c408525f0af7303d21ed5b81959e46876 (diff)
downloadmruby-d1e1bb0d5b45d9f1c5de943a036c86542698af49.tar.gz
mruby-d1e1bb0d5b45d9f1c5de943a036c86542698af49.zip
Remove `mrb_alloca()` function
When I found this function, I expected it to behave the same as the `alloca(3)` function, but it is accually the `mrb_alloca()` function does not free the heap until the `mrb_close()` function is called. Also, even if it is deleted, it can be replaced with the combination of the `MRB_TT_DATA` object and the `mrb_gv_set()` function if it is sure necessary.
Diffstat (limited to 'src/state.c')
-rw-r--r--src/state.c33
1 files changed, 0 insertions, 33 deletions
diff --git a/src/state.c b/src/state.c
index 08d7ba906..c42df71ba 100644
--- a/src/state.c
+++ b/src/state.c
@@ -57,38 +57,6 @@ mrb_default_allocf(mrb_state *mrb, void *p, size_t size, void *ud)
}
}
-struct alloca_header {
- struct alloca_header *next;
- char buf[1];
-};
-
-MRB_API void*
-mrb_alloca(mrb_state *mrb, size_t size)
-{
- struct alloca_header *p;
-
- p = (struct alloca_header*) mrb_malloc(mrb, sizeof(struct alloca_header)+size);
- p->next = mrb->mems;
- mrb->mems = p;
- return (void*)p->buf;
-}
-
-static void
-mrb_alloca_free(mrb_state *mrb)
-{
- struct alloca_header *p;
- struct alloca_header *tmp;
-
- if (mrb == NULL) return;
- p = mrb->mems;
-
- while (p) {
- tmp = p;
- p = p->next;
- mrb_free(mrb, tmp);
- }
-}
-
MRB_API mrb_state*
mrb_open(void)
{
@@ -256,7 +224,6 @@ mrb_close(mrb_state *mrb)
mrb_gc_free_gv(mrb);
mrb_free_context(mrb, mrb->root_c);
mrb_free_symtbl(mrb);
- mrb_alloca_free(mrb);
mrb_gc_destroy(mrb, &mrb->gc);
mrb_free(mrb, mrb);
}