From dc803f23bb43f5aa03619147792d36e509b148e1 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 9 Mar 2019 16:38:44 +0100 Subject: [PATCH] Add missing const --- m-algo.h | 25 +++++++++++++------------ m-i-list.h | 12 ++++++------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/m-algo.h b/m-algo.h index 714b073d..ce67a5d7 100644 --- a/m-algo.h +++ b/m-algo.h @@ -117,14 +117,14 @@ } \ \ static inline void \ - M_C(name, _find) (it_t it, container_t l, type_t const data) \ + M_C(name, _find) (it_t it, container_t const l, type_t const data) \ { \ M_CALL_IT_FIRST(cont_oplist, it, l); \ M_C(name, _find_again)(it, data); \ } \ \ static inline bool \ - M_C(name, _contain_p) (container_t l, type_t const data) \ + M_C(name, _contain_p) (container_t const l, type_t const data) \ { \ it_t it; \ M_C(name,_find)(it, l, data); \ @@ -153,7 +153,7 @@ M_IF_METHOD2(PREVIOUS, IT_LAST, cont_oplist) \ ( \ static inline void \ - M_C(name, _find_last) (it_t it, container_t l, type_t const data) \ + M_C(name, _find_last) (it_t it, container_t const l, type_t const data) \ { \ for (M_CALL_IT_LAST(cont_oplist, it, l); \ !M_CALL_IT_END_P(cont_oplist, it) ; \ @@ -166,7 +166,7 @@ , \ /* Otherwise search forward, but don't stop on the first occurence */ \ static inline void \ - M_C(name, _find_last) (it_t it, container_t l, type_t const data) \ + M_C(name, _find_last) (it_t it, container_t const l, type_t const data) \ { \ M_CALL_IT_END(cont_oplist, it, l); \ it_t it2; \ @@ -181,7 +181,7 @@ ) /* End of alternative of _find_last */ \ \ static inline size_t \ - M_C(name, _count) (container_t l, type_t const data) \ + M_C(name, _count) (container_t const l, type_t const data) \ { \ it_t it; \ size_t count = 0; \ @@ -195,7 +195,7 @@ } \ \ static inline size_t \ - M_C(name, _count_if) (container_t l, bool (*func)(type_t const data)) \ + M_C(name, _count_if) (container_t const l, bool (*func)(type_t const data)) \ { \ it_t it; \ size_t count = 0; \ @@ -222,7 +222,7 @@ } \ \ static inline void \ - M_C(name, _mismatch) (it_t it1, it_t it2, container_t l1, container_t l2 ) \ + M_C(name, _mismatch) (it_t it1, it_t it2, container_t const l1, container_t const l2 ) \ { \ M_CALL_IT_FIRST(cont_oplist, it1, l1); \ M_CALL_IT_FIRST(cont_oplist, it2, l2); \ @@ -243,7 +243,7 @@ } \ \ static inline void \ - M_C(name, _mismatch_if) (it_t it1, it_t it2, container_t l1, \ + M_C(name, _mismatch_if) (it_t it1, it_t it2, container_t const l1, \ container_t l2, bool (*func)(type_t const, type_t const) ) \ { \ M_CALL_IT_FIRST(cont_oplist, it1, l1); \ @@ -260,7 +260,8 @@ } \ \ static inline void \ - M_C(name, _reduce) (type_t *dest, container_t l, void (*f)(type_t *, type_t const) ) \ + M_C(name, _reduce) (type_t *dest, container_t const l, \ + void (*f)(type_t *, type_t const) ) \ { \ bool initDone = false; \ for M_EACH(item, l, cont_oplist) { \ @@ -275,7 +276,7 @@ \ static inline \ void M_C(name, _map_reduce) (type_t *dest, \ - container_t l, \ + const container_t l, \ void (*redFunc)(type_t*, type_t const), \ void (*mapFunc)(type_t*, type_t const) ) \ { \ @@ -295,7 +296,7 @@ } \ \ static inline bool \ - M_C(name, _any_of_p) (container_t l, bool (*f)(type_t const) ) \ + M_C(name, _any_of_p) (container_t const l, bool (*f)(type_t const) ) \ { \ for M_EACH(item, l, cont_oplist) { \ if (f(*item)) \ @@ -305,7 +306,7 @@ } \ \ static inline bool \ - M_C(name, _all_of_p) (container_t l, bool (*f)(type_t const) ) \ + M_C(name, _all_of_p) (container_t const l, bool (*f)(type_t const) ) \ { \ for M_EACH(item, l, cont_oplist) { \ if (!f(*item)) \ diff --git a/m-i-list.h b/m-i-list.h index f85c7976..3b7011ff 100644 --- a/m-i-list.h +++ b/m-i-list.h @@ -339,23 +339,23 @@ typedef struct ilist_head_s { } \ \ static inline void \ - M_C(name, _it_last)(list_it_t it, list_t list) \ + M_C(name, _it_last)(list_it_t it, list_t const list) \ { \ ILISTI_CONTRACT(name, list); \ assert (it != NULL); \ - it->head = &list->name; \ + it->head = list->name.next->prev; \ it->current = list->name.prev; \ - it->next = &list->name; \ + it->next = it->head; \ it->previous = list->name.prev->prev; \ ILISTI_NODE_CONTRACT(it->current); \ } \ \ static inline void \ - M_C(name, _it_end)(list_it_t it, list_t list) \ + M_C(name, _it_end)(list_it_t it, list_t const list) \ { \ assert (it != NULL && list != NULL); \ - it->head = &list->name; \ - it->current = &list->name; \ + it->head = list->name.next->prev; \ + it->current = it->head; \ it->next = list->name.next; \ it->previous = list->name.prev; \ ILISTI_NODE_CONTRACT(it->current); \