diff -r 9138acaa494b -r af6be1e123aa src/cx/list.h --- a/src/cx/list.h Tue Dec 28 17:24:18 2021 +0100 +++ b/src/cx/list.h Tue Dec 28 17:38:02 2021 +0100 @@ -47,7 +47,10 @@ /** * A comparator function comparing two list elements. */ -typedef int(*CxListComparator)(void const *left, void const *right); +typedef int(*CxListComparator)( + void const *left, + void const *right +); /** * Internal type for the list structure - use CxList instead. @@ -61,29 +64,42 @@ /** * Member function for adding an element. */ - int (*add)(cx_list_s *list, void *elem); + int (*add)( + cx_list_s *list, + void const *elem + ); /** * Member function for inserting an element. */ - int (*insert)(cx_list_s *list, size_t index, void *elem); + int (*insert)( + cx_list_s *list, + size_t index, + void const *elem + ); /** * Member function for removing an element. */ - int (*remove)(cx_list_s *list, size_t index); + int (*remove)( + cx_list_s *list, + size_t index + ); /** * Member function for element lookup. */ - void *(*at)(cx_list_s *list, size_t index); + void *(*at)( + cx_list_s const *list, + size_t index + ); /** * Member function for finding an element. */ size_t (*find)( - cx_list_s *list, - void *elem + cx_list_s const *list, + void const *elem ); /** @@ -95,8 +111,8 @@ * Member function for comparing this list to another list of the same type. */ int (*compare)( - cx_list_s *list, - cx_list_s *other + cx_list_s const *list, + cx_list_s const *other ); } cx_list_class; @@ -147,7 +163,10 @@ * @param elem a pointer to the element to add * @return zero on success, non-zero on memory allocation failure */ -static inline int cxListAdd(CxList list, void *elem) { +static inline int cxListAdd( + CxList list, + void const *elem +) { return list->cl->add(list, elem); } @@ -167,7 +186,11 @@ * @return zero on success, non-zero on memory allocation failure * or when the index is out of bounds */ -static inline int cxListInsert(CxList list, size_t index, void *elem) { +static inline int cxListInsert( + CxList list, + size_t index, + void const *elem +) { return list->cl->insert(list, index, elem); } @@ -177,7 +200,10 @@ * @param index the index of the element * @return zero on success, non-zero if the index is out of bounds */ -static inline int cxListRemove(CxList list, size_t index) { +static inline int cxListRemove( + CxList list, + size_t index +) { return list->cl->remove(list, index); } @@ -188,7 +214,10 @@ * @param index the index of the element * @return a pointer to the element or \c NULL if the index is out of bounds */ -static inline void *cxListAt(CxList list, size_t index) { +static inline void *cxListAt( + CxList list, + size_t index +) { return list->cl->at(list, index); } @@ -201,7 +230,10 @@ * @param elem the element to find * @return the index of the element or \c (size+1) if the element is not found */ -static inline size_t cxListFind(CxList list, void *elem) { +static inline size_t cxListFind( + CxList list, + void const *elem +) { return list->cl->find(list, elem); }