Additional doubly-linked list functions

This patch adds a few new functions for working with doubly-linked
lists.  The functions for adding single elements to a list have more
descriptive names, and there are now functions for moving an entire list
of elements into some other list (in constant time).

Additionally, the function for mapping through a list has replaced with
a function for “visiting” each element.  This is mainly to make the
function signatures more consistent with our other callback-based
functionality — you can abort the iteration with a non-zero result code,
and the `user_data` parameter is first.

Lastly, there are now helper macros for iterating through a list
yourself, rather than using a visitor callback.  See the documentation
or test case on how to use it.