Change in libosmo-sccp[master]: add osmo_xua_msg_tall_ctx_init()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Jul 12 18:53:54 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9953 )

Change subject: add osmo_xua_msg_tall_ctx_init()
......................................................................

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
---
M include/osmocom/sigtran/xua_msg.h
M src/xua_msg.c
2 files changed, 9 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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 @@
 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)
 {

-- 
To view, visit https://gerrit.osmocom.org/9953
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I618878680a096a7f7fc2d83098590f2e4cb08870
Gerrit-Change-Number: 9953
Gerrit-PatchSet: 2
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180712/e8183abd/attachment.htm>


More information about the gerrit-log mailing list