New for-each implementation that keeps a safe pointer to the next element
so you can remove the current element from the list.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This adds a generic double-linked list implementation so we don't have to
write all list-handling over and over again.
The list-type is similar to the kernel list where we use the same type for
heads and entries. This is a _very_ convenient list-type so we copy it.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This uses the GCC extension "typeof" to implement a type-safe "offsetof"
similar to the implementation in the linux kernel.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We want to move away from glib eventually. Until then, we use a simple
wrapper around the hash-table functions so we need to change a single
place only.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
When deleting a hook we should not search for the callback only. Otherwise
we might remove the wrong callback. Therefore, we now search for callback
and data argument. If multiple callbacks are registered with the same data
and cb, then we don't care which one is removed as this wouldn't make any
difference. They behave the same way, anyway.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The hook structure can be used to provide a central hook where other
subsystems can register callbacks.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>