Fixed memory leaks in new decoder

This commit is contained in:
Ismael Gomez 2018-09-07 14:05:45 +02:00
parent bc9d342959
commit 826fbccf11
3 changed files with 18 additions and 12 deletions

View File

@ -603,10 +603,12 @@ int MAKE_FUNC(init)(void **hh, uint32_t max_long_cb)
void MAKE_FUNC(free)(void *hh)
{
MAKE_TYPE *h = (MAKE_TYPE*) hh;
if (h->beta) {
free(h->beta);
if (h) {
if (h->beta) {
free(h->beta);
}
free(h);
}
bzero(h, sizeof(MAKE_TYPE));
}
void MAKE_FUNC(dec)(void *hh, llr_t *input, llr_t *app, llr_t *parity, llr_t *output, uint32_t long_cb)

View File

@ -215,10 +215,12 @@ int tdec_gen_init(void **hh, uint32_t max_long_cb)
void tdec_gen_free(void *hh)
{
tdec_gen_t *h = (tdec_gen_t*) hh;
if (h->beta) {
free(h->beta);
if (h) {
if (h->beta) {
free(h->beta);
}
free(h);
}
bzero(h, sizeof(tdec_gen_t));
}
void tdec_gen_dec(void *hh, int16_t *input, int16_t *app, int16_t *parity, int16_t *output, uint32_t long_cb)

View File

@ -379,13 +379,15 @@ void tdec_sse_free(void *hh)
{
tdec_sse_t *h = (tdec_sse_t*) hh;
if (h->alpha) {
free(h->alpha);
if (h) {
if (h->alpha) {
free(h->alpha);
}
if (h->branch) {
free(h->branch);
}
free(h);
}
if (h->branch) {
free(h->branch);
}
bzero(h, sizeof(tdec_sse_t));
}
/* Runs one instance of a decoder */