* Caution: this is O(n); consider using slist_delete_current() instead.
*/
void
-slist_delete(slist_head *head, slist_node *node)
+slist_delete(slist_head *head, const slist_node *node)
{
slist_node *last = &head->head;
slist_node *cur;
* Validate that 'node' is a member of 'head'
*/
void
-dlist_member_check(dlist_head *head, dlist_node *node)
+dlist_member_check(const dlist_head *head, const dlist_node *node)
{
dlist_iter iter;
* Verify integrity of a doubly linked list
*/
void
-dlist_check(dlist_head *head)
+dlist_check(const dlist_head *head)
{
dlist_node *cur;
* Verify integrity of a singly linked list
*/
void
-slist_check(slist_head *head)
+slist_check(const slist_head *head)
{
slist_node *cur;
/* Prototypes for functions too big to be inline */
/* Caution: this is O(n); consider using slist_delete_current() instead */
-extern void slist_delete(slist_head *head, slist_node *node);
+extern void slist_delete(slist_head *head, const slist_node *node);
#ifdef ILIST_DEBUG
-extern void dlist_member_check(dlist_head *head, dlist_node *node);
-extern void dlist_check(dlist_head *head);
-extern void slist_check(slist_head *head);
+extern void dlist_member_check(const dlist_head *head, const dlist_node *node);
+extern void dlist_check(const dlist_head *head);
+extern void slist_check(const slist_head *head);
#else
/*
* These seemingly useless casts to void are here to keep the compiler quiet
* An empty list has either its first 'next' pointer set to NULL, or to itself.
*/
static inline bool
-dlist_is_empty(dlist_head *head)
+dlist_is_empty(const dlist_head *head)
{
dlist_check(head);
* Caution: unreliable if 'node' is not in the list.
*/
static inline bool
-dlist_has_next(dlist_head *head, dlist_node *node)
+dlist_has_next(const dlist_head *head, const dlist_node *node)
{
return node->next != &head->head;
}
* Caution: unreliable if 'node' is not in the list.
*/
static inline bool
-dlist_has_prev(dlist_head *head, dlist_node *node)
+dlist_has_prev(const dlist_head *head, const dlist_node *node)
{
return node->prev != &head->head;
}
* Returns true if the list is empty, otherwise false.
*/
static inline bool
-dclist_is_empty(dclist_head *head)
+dclist_is_empty(const dclist_head *head)
{
Assert(dlist_is_empty(&head->dlist) == (head->count == 0));
return (head->count == 0);
* Caution: 'node' must be a member of 'head'.
*/
static inline bool
-dclist_has_next(dclist_head *head, dlist_node *node)
+dclist_has_next(const dclist_head *head, const dlist_node *node)
{
dlist_member_check(&head->dlist, node);
Assert(head->count > 0);
* Caution: 'node' must be a member of 'head'.
*/
static inline bool
-dclist_has_prev(dclist_head *head, dlist_node *node)
+dclist_has_prev(const dclist_head *head, const dlist_node *node)
{
dlist_member_check(&head->dlist, node);
Assert(head->count > 0);
* Returns the stored number of entries in 'head'
*/
static inline uint32
-dclist_count(dclist_head *head)
+dclist_count(const dclist_head *head)
{
Assert(dlist_is_empty(&head->dlist) == (head->count == 0));
* Is the list empty?
*/
static inline bool
-slist_is_empty(slist_head *head)
+slist_is_empty(const slist_head *head)
{
slist_check(head);
* Check whether 'node' has a following node.
*/
static inline bool
-slist_has_next(slist_head *head, slist_node *node)
+slist_has_next(const slist_head *head, const slist_node *node)
{
slist_check(head);