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
     1.1 --- a/src/cx/linked_list.h	Mon Dec 20 11:17:06 2021 +0100
     1.2 +++ b/src/cx/linked_list.h	Mon Dec 20 11:26:39 2021 +0100
     1.3 @@ -169,8 +169,8 @@
     1.4   * addresses are provided, the pointers are adjusted accordingly.
     1.5   *
     1.6   * The following combinations of arguments are valid (more arguments are optional):
     1.7 - * \li \p loc_next and \p loc_prev
     1.8 - * \li \p loc_next and \p begin
     1.9 + * \li \p loc_next and \p loc_prev (ancestor node is determined by using the prev pointer, overall O(1) performance)
    1.10 + * \li \p loc_next and \p begin (ancestor node is determined by list traversal, overall O(n) performance)
    1.11   *
    1.12   * \remark The \c next and \c prev pointers of the removed node are not cleared by this function and may still be used
    1.13   * to traverse to a former adjacent node in the list.
    1.14 @@ -181,7 +181,8 @@
    1.15   * @param loc_next the location of a \c next pointer within your node struct (required)
    1.16   * @param node the node to remove
    1.17   */
    1.18 -void cx_linked_list_remove(void **begin, void **end, ptrdiff_t loc_prev, ptrdiff_t loc_next, void *node);
    1.19 + void cx_linked_list_remove(void **begin, void **end, ptrdiff_t loc_prev, ptrdiff_t loc_next, void *node)
    1.20 + __attribute__ ((nonnull(5)));
    1.21  
    1.22  
    1.23  /**
     2.1 --- a/src/linked_list.c	Mon Dec 20 11:17:06 2021 +0100
     2.2 +++ b/src/linked_list.c	Mon Dec 20 11:26:39 2021 +0100
     2.3 @@ -138,6 +138,7 @@
     2.4  }
     2.5  
     2.6  void cx_linked_list_remove(void **begin, void **end, ptrdiff_t loc_prev, ptrdiff_t loc_next, void *node) {
     2.7 +    assert(node != NULL);
     2.8      assert(loc_next >= 0);
     2.9      assert(loc_prev >= 0 || begin != NULL);
    2.10  

mercurial