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
This commit is contained in:
parent
4ac8009c29
commit
e39f6cd752
|
@ -28,6 +28,7 @@
|
||||||
#include <smpp34.h>
|
#include <smpp34.h>
|
||||||
#include <smpp34_structs.h>
|
#include <smpp34_structs.h>
|
||||||
#include <smpp34_params.h>
|
#include <smpp34_params.h>
|
||||||
|
#include <smpp34_heap.h>
|
||||||
|
|
||||||
#include <osmocom/core/utils.h>
|
#include <osmocom/core/utils.h>
|
||||||
#include <osmocom/core/msgb.h>
|
#include <osmocom/core/msgb.h>
|
||||||
|
@ -52,6 +53,31 @@
|
||||||
#define VSUB_USE_SMPP "SMPP"
|
#define VSUB_USE_SMPP "SMPP"
|
||||||
#define VSUB_USE_SMPP_CMD "SMPP-cmd"
|
#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 */
|
/*! \brief find vlr_subscr for a given SMPP NPI/TON/Address */
|
||||||
static struct vlr_subscr *subscr_by_dst(struct gsm_network *net,
|
static struct vlr_subscr *subscr_by_dst(struct gsm_network *net,
|
||||||
uint8_t npi, uint8_t ton,
|
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");
|
LOGP(DSMPP, LOGL_FATAL, "Cannot allocate smsc struct\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
smpp34_set_memory_functions(&smpp34_talloc);
|
||||||
return smpp_vty_init();
|
return smpp_vty_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue