while (1) { iter.ptr = acl_ring_pop_head(&head); if (iter.ptr == NULL) break; dummy = acl_ring_to_appl(iter.ptr, DUMMY, entry); acl_myfree(dummy); } }
#ifndef ACL_RING_INCLUDE_H
#define ACL_RING_INCLUDE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
};
#define ACL_RING_SUCC(c) ((c)->succ)
#define acl_ring_succ ACL_RING_SUCC
#define ACL_RING_PRED(c) ((c)->pred)
#define acl_ring_pred ACL_RING_PRED
#define ACL_RING_TO_APPL(ring_ptr, app_type, ring_member) \
((app_type *) (((char *) (ring_ptr)) - offsetof(app_type,ring_member)))
#define acl_ring_to_appl ACL_RING_TO_APPL
#define ACL_RING_FOREACH(iter, head_ptr) \
for ((iter).ptr = acl_ring_succ((head_ptr)); (iter).ptr != (head_ptr); \
(iter).ptr = acl_ring_succ((iter).ptr))
#define acl_ring_foreach ACL_RING_FOREACH
#define ACL_RING_FOREACH_REVERSE(iter, head_ptr) \
for ((iter).ptr = acl_ring_pred((head_ptr)); (iter).ptr != (head_ptr); \
(iter).ptr = acl_ring_pred((iter).ptr))
#define acl_ring_foreach_reverse ACL_RING_FOREACH_REVERSE
#define ACL_RING_FIRST(head) \
(acl_ring_succ(head) != (head) ? acl_ring_succ(head) : 0)
#define acl_ring_first ACL_RING_FIRST
#define ACL_RING_FIRST_APPL(head, app_type, ring_member) \
(acl_ring_succ(head) != (head) ? \
ACL_RING_TO_APPL(acl_ring_succ(head), app_type, ring_member) : 0)
#define acl_ring_first_appl ACL_RING_FIRST_APPL
#define ACL_RING_LAST(head) \
(acl_ring_pred(head) != (head) ? acl_ring_pred(head) : 0)
#define acl_ring_last ACL_RING_LAST
#define ACL_RING_LAST_APPL(head, app_type, ring_member) \
(acl_ring_pred(head) != (head) ? \
ACL_RING_TO_APPL(acl_ring_pred(head), app_type, ring_member) : 0)
#define acl_ring_last_appl ACL_RING_LAST_APPL
#define ACL_RING_APPEND(ring_in, entry_in) do { \
ACL_RING *ring_ptr = (ring_in), *entry_ptr = (entry_in); \
entry_ptr->succ = ring_ptr->succ; \
entry_ptr->pred = ring_ptr; \
entry_ptr->parent = ring_ptr->parent; \
ring_ptr->succ->pred = entry_ptr; \
ring_ptr->succ = entry_ptr; \
ring_ptr->parent->len++; \
} while (0)
#define ACL_RING_PREPEND(ring_in, entry_in) do { \
ACL_RING *ring_ptr = (ring_in), *entry_ptr = (entry_in); \
entry_ptr->pred = ring_ptr->pred; \
entry_ptr->succ = ring_ptr; \
entry_ptr->parent = ring_ptr->parent; \
ring_ptr->pred->succ = entry_ptr; \
ring_ptr->pred = entry_ptr; \
ring_ptr->parent->len++; \
} while (0)
#define ACL_RING_DETACH(entry_in) do { \
ACL_RING *succ, *pred, *entry_ptr = (entry_in); \
succ = entry_ptr->succ; \
pred = entry_ptr->pred; \
if (succ != NULL && pred != NULL) { \
pred->succ = succ; \
succ->pred = pred; \
entry_ptr->parent->len--; \
entry_ptr->succ = entry_ptr->pred = NULL; \
} \
} while (0)
#ifdef __cplusplus
}
#endif
#endif