From 03a74d7b41e3abce86f9465a6a4994edb5c37e5b Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sat, 8 Feb 2020 22:31:24 -0500 Subject: ffmgr now uses allocr --- eval.c | 6 +----- foreign.c | 17 ++--------------- main.c | 6 +----- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/eval.c b/eval.c index d0b9e6c..b78ea45 100644 --- a/eval.c +++ b/eval.c @@ -16,11 +16,7 @@ static void evalr_create(Evaluator *ev, Typer *tr, Allocator *allocr) { ev->typer = tr; ev->enabled = true; ev->allocr = allocr; - ffmgr_create(&ev->ffmgr); -} - -static void evalr_free(Evaluator *ev) { - ffmgr_free(&ev->ffmgr); + ffmgr_create(&ev->ffmgr, ev->allocr); } static inline void *evalr_malloc(Evaluator *ev, size_t bytes) { diff --git a/foreign.c b/foreign.c index 36cdd82..2c1e54a 100644 --- a/foreign.c +++ b/foreign.c @@ -264,8 +264,8 @@ static bool arg_list_add(av_alist *arg_list, Value *val, Type *type, Location wh return true; } -static void ffmgr_create(ForeignFnManager *ffmgr) { - str_hash_table_create(&ffmgr->libs_loaded, sizeof(Library), NULL); +static void ffmgr_create(ForeignFnManager *ffmgr, Allocator *allocr) { + str_hash_table_create(&ffmgr->libs_loaded, sizeof(Library), allocr); } static bool foreign_call(ForeignFnManager *ffmgr, FnExpr *fn, Type *fn_type, Value *args, Location call_where, Value *ret) { @@ -315,16 +315,6 @@ static bool foreign_call(ForeignFnManager *ffmgr, FnExpr *fn, Type *fn_type, Val return true; } -static void ffmgr_free(ForeignFnManager *ffmgr) { - arr_foreach(ffmgr->libs_loaded.slots, StrHashTableSlotPtr, slotp) { - if (*slotp) { - Library *lib = (void *)((*slotp)->data); - dlclose(lib->handle); - } - } - str_hash_table_free(&ffmgr->libs_loaded); -} - #else static void ffmgr_create(ForeignFnManager *ffmgr) { (void)ffmgr; @@ -336,8 +326,5 @@ static bool foreign_call(ForeignFnManager *ffmgr, FnExpr *fn, Type *fn_type, Val return false; } -static void ffmgr_free(ForeignFnManager *ffmgr) { - (void)ffmgr; -} #endif diff --git a/main.c b/main.c index 87881dc..dcf4e07 100644 --- a/main.c +++ b/main.c @@ -18,10 +18,7 @@ /* TODO: -big leak check with tuples (see "TODO: tuples allocated here will never be freed!") -just make the ffmgr use the allocr ---- -iterating over an array of arrays (make sure you do a leak check) +change the way arrays work (a := b, where b is an array probably shouldn't copy) struct parameters - to allow circular dependencies in types foo, _ := bar(); nice syntax for #including something into a namespace @@ -140,7 +137,6 @@ int main(int argc, char **argv) { } allocr_free_all(&main_allocr); - evalr_free(&ev); fclose(out); return 0; } -- cgit v1.2.3