/**
* @brief Push an event and wake up module's event worker
*/
-static void event_push(gpointer data, gpointer user_data)
+static void event_push(struct module *module, void *user_data)
{
- struct module *module = data;
struct event *event = user_data;
if (!module || !event) {
return NULL;
}
-API void module_foreach(GFunc func, gpointer user_data)
+API void module_foreach(module_foreach_func func, void *user_data)
{
- g_slist_foreach(module_list, func, user_data);
+ struct module *module;
+
+ if (!func) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ G_SLIST_FOREACH(module_list, module)
+ func(module, user_data);
}
-static void module_init(gpointer data, gpointer user_data)
+static void module_init(struct module *module, void *user_data)
{
- struct module *module = data;
int *num_successful = (int *)user_data;
int ret;
return num_successful;
}
-static void module_exit(gpointer data, gpointer user_data)
+static void module_exit(struct module *module, void *user_data)
{
- struct module *module = data;
int ret;
if (module->event_handler) {
struct event_worker *event_worker;
};
+typedef void (*module_foreach_func) (struct module *module, void *user_data);
+
/**
* @brief Attach module to the module list
* @param[in] module Module structure
* @param[in] func Function to call with each module
* @param[in] user_data Argument to pass to the func
*/
-void module_foreach(GFunc func, gpointer user_data);
+void module_foreach(module_foreach_func func, void *user_data);
/**
* @brief Initialize all modules in the module list