Commit 4262cd9f authored by Matthias Braun's avatar Matthias Braun
Browse files

cleanup

parent aaa99f08
......@@ -16,32 +16,31 @@ hook_entry_t *hooks[hook_last];
void register_hook(hook_type_t hook, hook_entry_t *entry)
{
/* check if a hook function is specified. It's a union, so no matter which one */
if (! entry->hook._hook_turn_into_id)
return;
/* check if a hook function is specified. It's a union, so no matter which one */
if (!entry->hook._hook_turn_into_id)
return;
/* hook should not be registered yet */
assert(entry->next == NULL && hooks[hook] != entry);
/* hook should not be registered yet */
assert(entry->next == NULL && hooks[hook] != entry);
entry->next = hooks[hook];
hooks[hook] = entry;
entry->next = hooks[hook];
hooks[hook] = entry;
}
void unregister_hook(hook_type_t hook, hook_entry_t *entry)
{
hook_entry_t *p;
if (hooks[hook] == entry) {
hooks[hook] = entry->next;
entry->next = NULL;
return;
}
for (p = hooks[hook]; p && p->next != entry; p = p->next) {
}
if (p) {
p->next = entry->next;
entry->next = NULL;
}
if (hooks[hook] == entry) {
hooks[hook] = entry->next;
entry->next = NULL;
return;
}
hook_entry_t *p;
for (p = hooks[hook]; p && p->next != entry; p = p->next) {
}
if (p != NULL) {
p->next = entry->next;
entry->next = NULL;
}
}
......@@ -224,12 +224,12 @@ extern hook_entry_t *hooks[hook_last];
* Executes the hook @p what with the args @p args
* Do not use this macro directly.
*/
#define hook_exec(what, args) do { \
hook_entry_t *_p; \
for (_p = hooks[what]; _p; _p = _p->next){ \
void *hook_ctx_ = _p->context; \
_p->hook._##what args; \
} \
#define hook_exec(what, args) do { \
hook_entry_t *_p; \
for (_p = hooks[what]; _p; _p = _p->next){ \
void *hook_ctx_ = _p->context; \
_p->hook._##what args; \
} \
} while (0)
/** Called when a new node opcode has been created */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment