✨ feat(module manager): store spec path and cb name
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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*))));
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user