Add new List functions and macros for convenience

Introduce add_new_node{_tail,}() and list_for_each_unlink() in List to
facilitate working with lists. The former two internally create a node for
the given data and add it to the list. The latter automatically unlinks and
destroys the current node in an enumeration.

Take the opportunity to use them in all related places and make some
functions smaller.

Fix possible hooks[slot] corruption due to missing lock.

Which brought another strangeness in hook.c to light: uninstall_hook() could
never ever have counted its 'pos' variable correctly. Wait -- unless
install_hook() calculated its very one the same wrong way. Hmm, but maybe
they are doing it wrong now after my changes but who cares as long as they
are sync? It's late already and the issues have been fixed...

Fix add_nodes_tail() argument order in timer.c and event.c. Good thing it
worked with the linked list design in either order :-) Well, actually the
item was then linked to the wrong end of the list but nevermind. Though it's
a funny anecdote.

Fix possible node irritation when enumerating config_pool in config_exit as
the non-'safe' macro was used despite unlinking the enumerator.