diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2018-07-11 02:58:00 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2018-07-12 05:25:56 +0200 |
commit | 28c8a4bf2fbee013a2c82e19063940ec4cc80414 (patch) | |
tree | 40ed24c820f77119abe712afd623d6107ab3d719 /src/xua_msg.c | |
parent | 6f103ae2b57f769d1e2f4193f26de5c414ae0d94 (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
Diffstat (limited to 'src/xua_msg.c')
-rw-r--r-- | src/xua_msg.c | 8 |
1 files changed, 7 insertions, 1 deletions
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) { |