1 /* Licensed under LGPLv2.1+ - see LICENSE file for details */
6 static void *corrupt(const char *abortstr
,
7 const struct ccan_list_node
*head
,
8 const struct ccan_list_node
*node
,
13 "%s: prev corrupt in node %p (%u) of %p\n",
14 abortstr
, node
, count
, head
);
20 struct ccan_list_node
*ccan_list_check_node(const struct ccan_list_node
*node
,
23 const struct ccan_list_node
*p
, *n
;
26 for (p
= node
, n
= node
->next
; n
!= node
; p
= n
, n
= n
->next
) {
29 return corrupt(abortstr
, node
, n
, count
);
31 /* Check prev on head node. */
33 return corrupt(abortstr
, node
, node
, 0);
35 return (struct ccan_list_node
*)node
;
38 struct ccan_list_head
*ccan_list_check(const struct ccan_list_head
*h
, const char *abortstr
)
40 if (!ccan_list_check_node(&h
->n
, abortstr
))
42 return (struct ccan_list_head
*)h
;