33 static pthread_mutex_t
mutex = PTHREAD_MUTEX_INITIALIZER;
38 pthread_mutex_lock (&
mutex);
41 hooks = g_hash_table_new_full (g_str_hash, g_str_equal,
42 (GDestroyNotify)
str_unref, (GDestroyNotify) g_queue_free);
44 GQueue * list = g_hash_table_lookup (
hooks, name);
47 g_hash_table_insert (
hooks,
str_get (name), list = g_queue_new ());
55 g_queue_push_tail (list, item);
57 pthread_mutex_unlock (&
mutex);
62 pthread_mutex_lock (&
mutex);
67 GQueue * list = g_hash_table_lookup (
hooks, name);
72 for (GList * node = list->head; node;)
75 GList * next = node->next;
77 if (item->
func == func && (! user || item->
user == user))
83 g_queue_delete_link (list, node);
92 g_hash_table_remove (
hooks, name);
95 pthread_mutex_unlock (&
mutex);
100 pthread_mutex_lock (&
mutex);
105 GQueue * list = g_hash_table_lookup (
hooks, name);
110 for (GList * node = list->head; node;)
117 pthread_mutex_unlock (&
mutex);
121 pthread_mutex_lock (&
mutex);
125 GList * next = node->next;
129 g_queue_delete_link (list, node);
137 g_hash_table_remove (
hooks, name);
140 pthread_mutex_unlock (&
mutex);
static pthread_mutex_t mutex
EXPORT void hook_dissociate_full(const char *name, HookFunction func, void *user)
void(* HookFunction)(void *data, void *user)
EXPORT void hook_associate(const char *name, HookFunction func, void *user)
static GHashTable * hooks
void str_unref(char *str)
EXPORT void hook_call(const char *name, void *data)
char * str_get(const char *str)