diff --git a/infra/module_manager/module_manager.c b/infra/module_manager/module_manager.c index 22491d3..3006bee 100644 --- a/infra/module_manager/module_manager.c +++ b/infra/module_manager/module_manager.c @@ -62,9 +62,9 @@ int module_specs_load(toml_table_t* conf, struct module_spec_load **mod_spec) if (!mod_spec[i]->on_exit_cb) { fprintf(stderr, "Could not load exit function %s: %s\n", exit_func_name, dlerror()); } - FREE(path); - FREE(init_func_name); - FREE(exit_func_name); + mod_spec[i]->path=path; + mod_spec[i]->init_cb_name=init_func_name; + mod_spec[i]->exit_cb_name=exit_func_name; } return mod_num; MODULE_SPEC_LOAD_ERROR: @@ -127,6 +127,9 @@ void stellar_module_manager_free(struct stellar_module_manager *mod_mgr) { mod_mgr->schema.module_specs[i].on_exit_cb(mod_mgr, mod_mgr->schema.module_specs[i].mod); } + if(mod_mgr->schema.module_specs[i].path)FREE(mod_mgr->schema.module_specs[i].path); + if(mod_mgr->schema.module_specs[i].init_cb_name)FREE(mod_mgr->schema.module_specs[i].init_cb_name); + if(mod_mgr->schema.module_specs[i].exit_cb_name)FREE(mod_mgr->schema.module_specs[i].exit_cb_name); } FREE(mod_mgr->schema.module_specs); } diff --git a/infra/module_manager/module_manager_interna.h b/infra/module_manager/module_manager_interna.h index e6b1e81..7d28b50 100644 --- a/infra/module_manager/module_manager_interna.h +++ b/infra/module_manager/module_manager_interna.h @@ -24,6 +24,9 @@ struct module_spec_load struct stellar_module *mod; module_on_init_func *on_init_cb; module_on_exit_func *on_exit_cb; + char *path; + char *init_cb_name; + char *exit_cb_name; bool is_init_succ; }__attribute__((aligned(sizeof(void*)))); diff --git a/infra/module_manager/test/gtest_module_manager_main.cpp b/infra/module_manager/test/gtest_module_manager_main.cpp index 7f0dc9a..74aa611 100644 --- a/infra/module_manager/test/gtest_module_manager_main.cpp +++ b/infra/module_manager/test/gtest_module_manager_main.cpp @@ -39,6 +39,10 @@ TEST(module_manager_internal, module_specs_load) { EXPECT_EQ(specs[0].on_init_cb, gtest_mock_init); EXPECT_EQ(specs[0].on_exit_cb, gtest_mock_exit); + + if(specs->path)free(specs->path); + if(specs->init_cb_name)free(specs->init_cb_name); + if(specs->exit_cb_name)free(specs->exit_cb_name); free(specs); toml_free(conf);