lynxis lazus has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ggsn/+/38930?usp=email )


Change subject: gtp_new(): use talloc instead of calloc/free
......................................................................

gtp_new(): use talloc instead of calloc/free

Required for SGSN Context Req fsm which is using talloc.

Change-Id: I7c4a29c4bb1ef3c7bf506e59e99b3a804cabe34b
---
M gtp/gsn.c
M gtp/gsn_internal.h
2 files changed, 11 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/30/38930/1

diff --git a/gtp/gsn.c b/gtp/gsn.c
index 612baf2..b620279 100644
--- a/gtp/gsn.c
+++ b/gtp/gsn.c
@@ -116,6 +116,8 @@
        {}
 };

+void *tall_gsn_ctx;
+

 /* API Functions */

@@ -466,7 +468,7 @@
 {
        LOGP(DLGTP, LOGL_NOTICE, "GTP: gtp_newgsn() started at %s\n", 
inet_ntoa(*listen));

-       *gsn = calloc(sizeof(struct gsn_t), 1); /* TODO */
+       *gsn = talloc_zero(tall_gsn_ctx, struct gsn_t);

        (*gsn)->statedir = statedir;
        log_restart(*gsn);
@@ -551,7 +553,7 @@

        rate_ctr_group_free(gsn->ctrg);

-       free(gsn);
+       talloc_free(gsn);
        return 0;
 }

@@ -584,3 +586,8 @@
        /* dummy API, deprecated. Return a huge timer to do nothing */
        return 0;
 }
+
+static __attribute__((constructor)) void gtp_talloc_init(void)
+{
+       tall_gsn_ctx = talloc_named_const(NULL, 0, "libgtp");
+}
diff --git a/gtp/gsn_internal.h b/gtp/gsn_internal.h
index deb60c3..860d37b 100644
--- a/gtp/gsn_internal.h
+++ b/gtp/gsn_internal.h
@@ -1,3 +1,5 @@
 #pragma once

+extern void *tall_gsn_ctx;
+
 void gtp_queue_timer_start(struct gsn_t *gsn);

--
To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/38930?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I7c4a29c4bb1ef3c7bf506e59e99b3a804cabe34b
Gerrit-Change-Number: 38930
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <[email protected]>

Reply via email to