✨ feat(module manager): module new add ctx as parameter
This commit is contained in:
@@ -8,7 +8,7 @@ extern "C"
|
|||||||
#include "stellar/mq.h"
|
#include "stellar/mq.h"
|
||||||
|
|
||||||
struct stellar_module;
|
struct stellar_module;
|
||||||
struct stellar_module *stellar_module_new(const char *name);
|
struct stellar_module *stellar_module_new(const char *name, void *ctx);
|
||||||
void stellar_module_free(struct stellar_module *mod);
|
void stellar_module_free(struct stellar_module *mod);
|
||||||
|
|
||||||
void * stellar_module_get_ctx(struct stellar_module *mod);
|
void * stellar_module_get_ctx(struct stellar_module *mod);
|
||||||
|
|||||||
@@ -187,10 +187,11 @@ struct stellar_module *stellar_module_manager_get_module(struct stellar_module_m
|
|||||||
*******************************************/
|
*******************************************/
|
||||||
|
|
||||||
|
|
||||||
struct stellar_module *stellar_module_new(const char *name)
|
struct stellar_module *stellar_module_new(const char *name, void *ctx)
|
||||||
{
|
{
|
||||||
struct stellar_module *mod = CALLOC(struct stellar_module, 1);
|
struct stellar_module *mod = CALLOC(struct stellar_module, 1);
|
||||||
memcpy(mod->name, name, MIN(NAME_MAX, strlen(name)));
|
memcpy(mod->name, name, MIN(NAME_MAX, strlen(name)));
|
||||||
|
mod->module_ctx=ctx;
|
||||||
return mod;
|
return mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ TEST(module_manager_internal, stellar_module_manager_new_with_toml) {
|
|||||||
|
|
||||||
TEST(stellar_module, basic_new_and_free) {
|
TEST(stellar_module, basic_new_and_free) {
|
||||||
|
|
||||||
struct stellar_module *mod = stellar_module_new("test");
|
struct stellar_module *mod = stellar_module_new("test", NULL);
|
||||||
EXPECT_TRUE(mod!=NULL);
|
EXPECT_TRUE(mod!=NULL);
|
||||||
|
|
||||||
stellar_module_set_name(mod, "test1");
|
stellar_module_set_name(mod, "test1");
|
||||||
@@ -145,7 +145,7 @@ TEST(stellar_module_manager, register_thread) {
|
|||||||
|
|
||||||
extern "C" struct stellar_module *gtest_module_init(struct stellar_module_manager *mod_mgr)
|
extern "C" struct stellar_module *gtest_module_init(struct stellar_module_manager *mod_mgr)
|
||||||
{
|
{
|
||||||
struct stellar_module *mod = stellar_module_new("gtest");
|
struct stellar_module *mod = stellar_module_new("gtest", NULL);
|
||||||
EXPECT_STREQ(stellar_module_get_name(mod), "gtest");
|
EXPECT_STREQ(stellar_module_get_name(mod), "gtest");
|
||||||
stellar_module_set_ctx(mod, (void*)1);
|
stellar_module_set_ctx(mod, (void*)1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user