add more explicit documentation to cx_linked_list_remove()

Mon, 20 Dec 2021 11:26:39 +0100

author
Mike Becker <universe@uap-core.de>
date
Mon, 20 Dec 2021 11:26:39 +0100
changeset 477
73a93c7a56ae
parent 476
60ff4561dc04
child 478
599770bb6314

add more explicit documentation to cx_linked_list_remove()

also require nonnull node argument

src/cx/linked_list.h file | annotate | diff | comparison | revisions
src/linked_list.c file | annotate | diff | comparison | revisions
--- 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)));
 
 
 /**
--- 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);
 

mercurial