]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
queue.h: add missing TAILQ_SAFE_ENTRY()
authorJaroslav Kysela <perex@perex.cz>
Wed, 6 Mar 2019 19:08:29 +0000 (20:08 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 6 Mar 2019 19:08:29 +0000 (20:08 +0100)
src/queue.h

index 3388b46fc343fb54068560d3a3e91c780842edf6..70453a515c50ba94187a0f59f845a8e6fd1cacfa 100644 (file)
  * 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);                        \