From bcdd2cb33797412cce1f1014d265a71461676cff Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 24 Aug 2022 16:35:51 +0200 Subject: examples: add module search path initialization and freeing Since commit 3c168b5 ("vm, cli: move search path into global config...") it is required to explicitly initialize the module search path in the configuration structure for compile time module imports and run time require operations to work. Signed-off-by: Jo-Philipp Wich --- examples/exception-handler.c | 6 ++++++ examples/execute-file.c | 6 ++++++ examples/execute-string.c | 6 ++++++ examples/native-function.c | 6 ++++++ examples/state-reset.c | 6 ++++++ examples/state-reuse.c | 6 ++++++ 6 files changed, 36 insertions(+) diff --git a/examples/exception-handler.c b/examples/exception-handler.c index 324a350..290518a 100644 --- a/examples/exception-handler.c +++ b/examples/exception-handler.c @@ -74,6 +74,9 @@ int main(int argc, char **argv) return 1; } + /* initialize default module search path */ + uc_search_path_init(&config.module_search_path); + /* initialize VM context */ uc_vm_t vm = { 0 }; uc_vm_init(&vm, &config); @@ -96,5 +99,8 @@ int main(int argc, char **argv) /* free VM context */ uc_vm_free(&vm); + /* free search module path vector */ + uc_search_path_free(&config.module_search_path); + return exit_code; } diff --git a/examples/execute-file.c b/examples/execute-file.c index 1895cda..5c35b17 100644 --- a/examples/execute-file.c +++ b/examples/execute-file.c @@ -61,6 +61,9 @@ int main(int argc, char **argv) return 1; } + /* initialize default module search path */ + uc_search_path_init(&config.module_search_path); + /* initialize VM context */ uc_vm_t vm = { 0 }; uc_vm_init(&vm, &config); @@ -114,5 +117,8 @@ int main(int argc, char **argv) /* free VM context */ uc_vm_free(&vm); + /* free search module path vector */ + uc_search_path_free(&config.module_search_path); + return exit_code; } diff --git a/examples/execute-string.c b/examples/execute-string.c index fe5e8e9..edfab8b 100644 --- a/examples/execute-string.c +++ b/examples/execute-string.c @@ -71,6 +71,9 @@ int main(int argc, char **argv) return 1; } + /* initialize default module search path */ + uc_search_path_init(&config.module_search_path); + /* initialize VM context */ uc_vm_t vm = { 0 }; uc_vm_init(&vm, &config); @@ -127,5 +130,8 @@ int main(int argc, char **argv) /* free VM context */ uc_vm_free(&vm); + /* free search module path vector */ + uc_search_path_free(&config.module_search_path); + return exit_code; } diff --git a/examples/native-function.c b/examples/native-function.c index 5c2f6da..190c95c 100644 --- a/examples/native-function.c +++ b/examples/native-function.c @@ -77,6 +77,9 @@ int main(int argc, char **argv) return 1; } + /* initialize default module search path */ + uc_search_path_init(&config.module_search_path); + /* initialize VM context */ uc_vm_t vm = { 0 }; uc_vm_init(&vm, &config); @@ -103,5 +106,8 @@ int main(int argc, char **argv) /* free VM context */ uc_vm_free(&vm); + /* free search module path vector */ + uc_search_path_free(&config.module_search_path); + return exit_code; } diff --git a/examples/state-reset.c b/examples/state-reset.c index ce61e7f..92d48e0 100644 --- a/examples/state-reset.c +++ b/examples/state-reset.c @@ -59,6 +59,9 @@ int main(int argc, char **argv) return 1; } + /* initialize default module search path */ + uc_search_path_init(&config.module_search_path); + /* execute compiled program function five times */ for (int i = 0; i < 5; i++) { /* initialize VM context */ @@ -87,5 +90,8 @@ int main(int argc, char **argv) /* release program function */ uc_program_put(program); + /* free search module path vector */ + uc_search_path_free(&config.module_search_path); + return exit_code; } diff --git a/examples/state-reuse.c b/examples/state-reuse.c index f7321f6..c685e48 100644 --- a/examples/state-reuse.c +++ b/examples/state-reuse.c @@ -60,6 +60,9 @@ int main(int argc, char **argv) return 1; } + /* initialize default module search path */ + uc_search_path_init(&config.module_search_path); + /* initialize VM context */ uc_vm_t vm = { 0 }; uc_vm_init(&vm, &config); @@ -91,5 +94,8 @@ int main(int argc, char **argv) /* free VM context */ uc_vm_free(&vm); + /* free search module path vector */ + uc_search_path_free(&config.module_search_path); + return exit_code; } -- cgit v1.2.3