{
struct lde_addr *lde_addr;
- while ((lde_addr = TAILQ_FIRST(&ln->addr_list)) != NULL) {
- TAILQ_REMOVE(&ln->addr_list, lde_addr, entry);
+ while ((lde_addr = TAILQ_POP_FIRST(&ln->addr_list, entry)) != NULL)
free(lde_addr);
- }
}
static void zclient_sync_init(unsigned short instance)
#include "queue.h"
#include "imsg.h"
-int ibuf_realloc(struct ibuf *, size_t);
-void ibuf_enqueue(struct msgbuf *, struct ibuf *);
-void ibuf_dequeue(struct msgbuf *, struct ibuf *);
+static int ibuf_realloc(struct ibuf *, size_t);
+static void ibuf_enqueue(struct msgbuf *, struct ibuf *);
+static void ibuf_dequeue(struct msgbuf *, struct ibuf *);
struct ibuf *ibuf_open(size_t len)
{
return (buf);
}
-int ibuf_realloc(struct ibuf *buf, size_t len)
+static int ibuf_realloc(struct ibuf *buf, size_t len)
{
uint8_t *b;
next = TAILQ_NEXT(buf, entry);
if (buf->rpos + n >= buf->wpos) {
n -= buf->wpos - buf->rpos;
+
+ TAILQ_REMOVE(&msgbuf->bufs, buf, entry);
ibuf_dequeue(msgbuf, buf);
} else {
buf->rpos += n;
{
struct ibuf *buf;
- while ((buf = TAILQ_FIRST(&msgbuf->bufs)) != NULL)
+ while ((buf = TAILQ_POP_FIRST(&msgbuf->bufs, entry)) != NULL)
ibuf_dequeue(msgbuf, buf);
}
return (1);
}
-void ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf)
+static void ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf)
{
TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entry);
msgbuf->queued++;
}
-void ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf)
+static void ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf)
{
- TAILQ_REMOVE(&msgbuf->bufs, buf, entry);
-
+ /* TAILQ_REMOVE done by caller */
if (buf->fd != -1)
close(buf->fd);
#include "freebsd-queue.h"
#endif /* defined(__OpenBSD__) && !defined(STAILQ_HEAD) */
+#ifndef TAILQ_POP_FIRST
+#define TAILQ_POP_FIRST(head, field) \
+ ({ typeof((head)->tqh_first) _elm = TAILQ_FIRST(head); \
+ if (_elm) { \
+ if ((TAILQ_NEXT((_elm), field)) != NULL) \
+ TAILQ_NEXT((_elm), field)->field.tqe_prev = \
+ &TAILQ_FIRST(head); \
+ else \
+ (head)->tqh_last = &TAILQ_FIRST(head); \
+ TAILQ_FIRST(head) = TAILQ_NEXT((_elm), field); \
+ }; _elm; })
+#endif
+
#endif /* _FRR_QUEUE_H */