From 3fad5d782acbd97be1124ccab874741261913429 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 20 Nov 2017 14:15:03 +0100 Subject: msgb: add inline msgb_queue_free() Related: Iaad35f03e3bdfabf3ba82b16e563c0a5d1f03639 (libosmo-netif) Change-Id: Ia291832ca445d4071f0ed9a01730d945ff691cf7 --- include/osmocom/core/msgb.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/osmocom/core') diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h index 9c3ccf0d..335067ea 100644 --- a/include/osmocom/core/msgb.h +++ b/include/osmocom/core/msgb.h @@ -72,6 +72,15 @@ extern int msgb_resize_area(struct msgb *msg, uint8_t *area, extern struct msgb *msgb_copy(const struct msgb *msg, const char *name); static int msgb_test_invariant(const struct msgb *msg) __attribute__((pure)); +/*! Free all msgbs from a queue built with msgb_enqueue(). + * \param[in] queue list head of a msgb queue. + */ +static inline void msgb_queue_free(struct llist_head *queue) +{ + struct msgb *msg; + while ((msg = msgb_dequeue(queue))) msgb_free(msg); +} + #ifdef MSGB_DEBUG #include #define MSGB_ABORT(msg, fmt, args ...) do { \ -- cgit v1.2.3