# HG changeset patch # User Mike Becker # Date 1639995999 -3600 # Node ID 73a93c7a56ae7abb49b46a5bf1825c2c834f6a69 # Parent 60ff4561dc04a6b962c4a3a2a977c69843168fcf add more explicit documentation to cx_linked_list_remove() also require nonnull node argument diff -r 60ff4561dc04 -r 73a93c7a56ae src/cx/linked_list.h --- a/src/cx/linked_list.h Mon Dec 20 11:17:06 2021 +0100 +++ b/src/cx/linked_list.h Mon Dec 20 11:26:39 2021 +0100 @@ -169,8 +169,8 @@ * addresses are provided, the pointers are adjusted accordingly. * * The following combinations of arguments are valid (more arguments are optional): - * \li \p loc_next and \p loc_prev - * \li \p loc_next and \p begin + * \li \p loc_next and \p loc_prev (ancestor node is determined by using the prev pointer, overall O(1) performance) + * \li \p loc_next and \p begin (ancestor node is determined by list traversal, overall O(n) performance) * * \remark The \c next and \c prev pointers of the removed node are not cleared by this function and may still be used * to traverse to a former adjacent node in the list. @@ -181,7 +181,8 @@ * @param loc_next the location of a \c next pointer within your node struct (required) * @param node the node to remove */ -void cx_linked_list_remove(void **begin, void **end, ptrdiff_t loc_prev, ptrdiff_t loc_next, void *node); + void cx_linked_list_remove(void **begin, void **end, ptrdiff_t loc_prev, ptrdiff_t loc_next, void *node) + __attribute__ ((nonnull(5))); /** diff -r 60ff4561dc04 -r 73a93c7a56ae src/linked_list.c --- a/src/linked_list.c Mon Dec 20 11:17:06 2021 +0100 +++ b/src/linked_list.c Mon Dec 20 11:26:39 2021 +0100 @@ -138,6 +138,7 @@ } void cx_linked_list_remove(void **begin, void **end, ptrdiff_t loc_prev, ptrdiff_t loc_next, void *node) { + assert(node != NULL); assert(loc_next >= 0); assert(loc_prev >= 0 || begin != NULL);