* For sys/time.h and time.h
*/
#include <freeradius-devel/missing.h>
+#include <freeradius-devel/rad_assert.h>
#include <stdint.h>
#include <stdio.h>
#define FR_DLIST_INIT(head) do { head.prev = head.next = &head; } while (0)
static inline void fr_dlist_insert_head(fr_dlist_t *head, fr_dlist_t *entry)
{
+ if (!rad_cond_assert(head->next != NULL)) return;
+ if (!rad_cond_assert(head->prev != NULL)) return;
+
entry->prev = head;
entry->next = head->next;
- if (head->next) head->next->prev = entry; /* Head may be the only node in the list */
+ head->next->prev = entry;
head->next = entry;
}
static inline void fr_dlist_insert_tail(fr_dlist_t *head, fr_dlist_t *entry)
{
+ if (!rad_cond_assert(head->next != NULL)) return;
+ if (!rad_cond_assert(head->prev != NULL)) return;
+
entry->next = head;
entry->prev = head->prev;
head->prev->next = entry;
static inline void fr_dlist_remove(fr_dlist_t *entry)
{
+ if (!rad_cond_assert(entry->next != NULL)) return;
+ if (!rad_cond_assert(entry->prev != NULL)) return;
+
entry->prev->next = entry->next;
entry->next->prev = entry->prev;
entry->prev = entry->next = entry;