From: Jaroslav Kysela Date: Wed, 6 Mar 2019 19:08:29 +0000 (+0100) Subject: queue.h: add missing TAILQ_SAFE_ENTRY() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d64d8c808a35b1308c38168a15152f59c5b13a70;p=thirdparty%2Ftvheadend.git queue.h: add missing TAILQ_SAFE_ENTRY() --- diff --git a/src/queue.h b/src/queue.h index 3388b46fc..70453a515 100644 --- a/src/queue.h +++ b/src/queue.h @@ -68,6 +68,16 @@ * Extra TAILQ-ops */ +#define TAILQ_SAFE_ENTRY(elm, field) \ + ((elm)->field.tqe_next == NULL && (elm)->field.tqe_prev == NULL) + +#define TAILQ_SAFE_REMOVE(head, elm, field) \ + if ((elm)->field.tqe_next != NULL || (elm)->field.tqe_prev != NULL) { \ + TAILQ_REMOVE(head, elm, field); \ + (elm)->field.tqe_next = NULL; \ + (elm)->field.tqe_prev = NULL; \ + } + #define TAILQ_INSERT_SORTED(head, elm, field, cmpfunc) do { \ if(TAILQ_FIRST(head) == NULL) { \ TAILQ_INSERT_HEAD(head, elm, field); \