Change in osmo-msc[master]: smpp: Make libsmpp34 use talloc for its allocations

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Apr 9 22:35:56 UTC 2019


Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/13562


Change subject: smpp: Make libsmpp34 use talloc for its allocations
......................................................................

smpp: Make libsmpp34 use talloc for its allocations

We are just introducing smpp34_set_memory_functions() in libsmpp34
to allow applications like OsmoMSC to provide their own heap allocator
callback functions.  Let's used this to integrate with talloc and
hence allow talloc tracking/debugging for libsmpp34 internal
allocations.

Depends: libsmpp34 Change-Id I3656117115e89638c093bfbcbc4369ce302f7a94
Change-Id: Ie2725ffab6a225813e65768735f01678e2022128
Related: OS#3913
---
M src/libmsc/smpp_openbsc.c
1 file changed, 27 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/62/13562/1

diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index 9156445..b80b473 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -28,6 +28,7 @@
 #include <smpp34.h>
 #include <smpp34_structs.h>
 #include <smpp34_params.h>
+#include <smpp34_heap.h>
 
 #include <osmocom/core/utils.h>
 #include <osmocom/core/msgb.h>
@@ -48,6 +49,31 @@
 
 #include "smpp_smsc.h"
 
+/* talloc integration for libsmpp34 */
+
+static struct smsc *g_smsc;
+
+static void *smpp34_talloc_malloc(size_t sz)
+{
+	return talloc_size(g_smsc, sz);
+}
+
+static void *smpp34_talloc_realloc(void *ptr, size_t sz)
+{
+	return talloc_realloc_size(g_smsc, ptr, sz);
+}
+
+static void smpp34_talloc_free(void *ptr)
+{
+	talloc_free(ptr);
+}
+
+static const struct smpp34_memory_functions smpp34_talloc = {
+	.malloc_fun = smpp34_talloc_malloc,
+	.realloc_fun = smpp34_talloc_realloc,
+	.free_fun = smpp34_talloc_free,
+};
+
 /*! \brief find vlr_subscr for a given SMPP NPI/TON/Address */
 static struct vlr_subscr *subscr_by_dst(struct gsm_network *net,
 					    uint8_t npi, uint8_t ton,
@@ -739,8 +765,6 @@
 				deliver.sequence_number);
 }
 
-static struct smsc *g_smsc;
-
 int smpp_route_smpp_first(struct gsm_sms *sms, struct ran_conn *conn)
 {
 	return g_smsc->smpp_first;
@@ -779,6 +803,7 @@
 		LOGP(DSMPP, LOGL_FATAL, "Cannot allocate smsc struct\n");
 		return -1;
 	}
+	smpp34_set_memory_functions(&smpp34_talloc);
 	return smpp_vty_init();
 }
 

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

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie2725ffab6a225813e65768735f01678e2022128
Gerrit-Change-Number: 13562
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190409/b14e100c/attachment.html>


More information about the gerrit-log mailing list