aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-11-20 14:15:03 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2017-11-20 14:22:15 +0100
commit3fad5d782acbd97be1124ccab874741261913429 (patch)
treecc6df325658fc3b7c1a4865558745de871f6ff38 /include/osmocom
parentabcd0e37b77529dadfc296cda7aacfe31858d74d (diff)
msgb: add inline msgb_queue_free()
Diffstat (limited to 'include/osmocom')
-rw-r--r--include/osmocom/core/msgb.h9
1 files changed, 9 insertions, 0 deletions
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 <osmocom/core/panic.h>
#define MSGB_ABORT(msg, fmt, args ...) do { \