diff options
author | Harald Welte <laforge@gnumonks.org> | 2019-04-10 00:33:46 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2019-05-08 23:49:45 +0200 |
commit | e39f6cd7528895d9dd67a4d4ebddda764422776f (patch) | |
tree | 1402d06c6ddfb52153308da489d29cb6abd1eb5b /src/libmsc/smpp_openbsc.c | |
parent | 4ac8009c29889472848f5b25f45d8e7dbfb24a31 (diff) |
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
Diffstat (limited to 'src/libmsc/smpp_openbsc.c')
-rw-r--r-- | src/libmsc/smpp_openbsc.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c index e6eb0102a..bbfc5008f 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> @@ -52,6 +53,31 @@ #define VSUB_USE_SMPP "SMPP" #define VSUB_USE_SMPP_CMD "SMPP-cmd" +/* 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, @@ -790,6 +816,7 @@ int smpp_openbsc_alloc_init(void *ctx) LOGP(DSMPP, LOGL_FATAL, "Cannot allocate smsc struct\n"); return -1; } + smpp34_set_memory_functions(&smpp34_talloc); return smpp_vty_init(); } |