33 static pthread_mutex_t
mutex = PTHREAD_MUTEX_INITIALIZER;
44 pthread_mutex_lock (&
mutex);
48 (GDestroyNotify) g_queue_free);
50 GQueue * list = g_hash_table_lookup (
hooks, name);
53 g_hash_table_insert (
hooks,
str_get (name), list = g_queue_new ());
61 g_queue_push_tail (list, item);
63 pthread_mutex_unlock (&
mutex);
68 pthread_mutex_lock (&
mutex);
73 GQueue * list = g_hash_table_lookup (
hooks, name);
78 for (GList * node = list->head; node;)
81 GList * next = node->next;
83 if (item->
func == func && (! user || item->
user == user))
89 g_queue_delete_link (list, node);
98 g_hash_table_remove (
hooks, name);
101 pthread_mutex_unlock (&
mutex);
106 pthread_mutex_lock (&
mutex);
111 GQueue * list = g_hash_table_lookup (
hooks, name);
116 for (GList * node = list->head; node;)
123 pthread_mutex_unlock (&
mutex);
127 pthread_mutex_lock (&
mutex);
131 GList * next = node->next;
135 g_queue_delete_link (list, node);
143 g_hash_table_remove (
hooks, name);
146 pthread_mutex_unlock (&
mutex);
static pthread_mutex_t mutex
EXPORT void hook_dissociate_full(const char *name, HookFunction func, void *user)
static void str_unref_cb(void *str)
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)