diff options
authorNeels Hofmeyr <neels@hofmeyr.de>2018-07-11 02:58:00 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-07-12 05:25:56 +0200
commit28c8a4bf2fbee013a2c82e19063940ec4cc80414 (patch)
parent6f103ae2b57f769d1e2f4193f26de5c414ae0d94 (diff)
add osmo_xua_msg_tall_ctx_init()
So far the tall_xua ctx used to allocate from in xua_msg_alloc() was never initialized, actually hiding memory leaks from the talloc report. Add this API to allow branching the xua_msg ctx off a sane root ctx. Explicitly initialize tall_xua to NULL, so that, if xua_msg_ctx_init() isn't called, tall_xua is still guaranteed to not be a random pointer. osmo-bsc will use this function to hook the tall_xua ctx to osmo-bsc's own root ctx. Change-Id: I618878680a096a7f7fc2d83098590f2e4cb08870
2 files changed, 9 insertions, 1 deletions
diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h
index 423adbc..e912e02 100644
--- a/include/osmocom/sigtran/xua_msg.h
+++ b/include/osmocom/sigtran/xua_msg.h
@@ -69,6 +69,8 @@ struct xua_msg_event_map {
extern const struct xua_dialect xua_dialect_sua;
extern const struct xua_dialect xua_dialect_m3ua;
+void osmo_xua_msg_tall_ctx_init(void *ctx);
struct xua_msg *xua_msg_alloc(void);
void xua_msg_free(struct xua_msg *msg);
diff --git a/src/xua_msg.c b/src/xua_msg.c
index d56009f..ed0cdc7 100644
--- a/src/xua_msg.c
+++ b/src/xua_msg.c
@@ -33,7 +33,13 @@
#include <string.h>
#include <errno.h>
-static void *tall_xua;
+static void *tall_xua = NULL;
+/* Allocate the root talloc context used for xua_msg_alloc(). */
+void osmo_xua_msg_tall_ctx_init(void *ctx)
+ tall_xua = talloc_named_const(ctx, 0, "xua_msg");
struct xua_msg *xua_msg_alloc(void)