Moved a lot of spandsp to the use of custom allocation functions

This commit is contained in:
Steve Underwood 2013-08-06 00:49:15 +08:00
parent 7c744ce1d8
commit d5e4089c22
46 changed files with 233 additions and 187 deletions

View File

@ -46,6 +46,7 @@
#include <assert.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/logging.h"
#include "spandsp/queue.h"
@ -749,7 +750,7 @@ SPAN_DECLARE(ademco_contactid_receiver_state_t *) ademco_contactid_receiver_init
{
if (s == NULL)
{
if ((s = (ademco_contactid_receiver_state_t *) malloc(sizeof (*s))) == NULL)
if ((s = (ademco_contactid_receiver_state_t *) span_alloc(sizeof (*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -776,7 +777,7 @@ SPAN_DECLARE(int) ademco_contactid_receiver_release(ademco_contactid_receiver_st
SPAN_DECLARE(int) ademco_contactid_receiver_free(ademco_contactid_receiver_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -1084,7 +1085,7 @@ SPAN_DECLARE(ademco_contactid_sender_state_t *) ademco_contactid_sender_init(ade
{
if (s == NULL)
{
if ((s = (ademco_contactid_sender_state_t *) malloc(sizeof (*s))) == NULL)
if ((s = (ademco_contactid_sender_state_t *) span_alloc(sizeof (*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -1121,7 +1122,7 @@ SPAN_DECLARE(int) ademco_contactid_sender_release(ademco_contactid_sender_state_
SPAN_DECLARE(int) ademco_contactid_sender_free(ademco_contactid_sender_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -44,6 +44,7 @@
#include <assert.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/logging.h"
#include "spandsp/queue.h"
@ -426,7 +427,7 @@ SPAN_DECLARE(adsi_rx_state_t *) adsi_rx_init(adsi_rx_state_t *s,
{
if (s == NULL)
{
if ((s = (adsi_rx_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (adsi_rx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -465,7 +466,7 @@ SPAN_DECLARE(int) adsi_rx_release(adsi_rx_state_t *s)
SPAN_DECLARE(int) adsi_rx_free(adsi_rx_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -658,7 +659,7 @@ SPAN_DECLARE(adsi_tx_state_t *) adsi_tx_init(adsi_tx_state_t *s, int standard)
{
if (s == NULL)
{
if ((s = (adsi_tx_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (adsi_tx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -688,7 +689,7 @@ SPAN_DECLARE(int) adsi_tx_release(adsi_tx_state_t *s)
SPAN_DECLARE(int) adsi_tx_free(adsi_tx_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -48,11 +48,6 @@
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#if defined(HAVE_POSIX_MEMALIGN)
static void *fake_posix_memalign(size_t alignment, size_t size);
#endif
static void *fake_aligned_alloc(size_t alignment, size_t size);
span_alloc_t __span_alloc = malloc;
#if defined(HAVE_ALIGNED_ALLOC)
span_aligned_alloc_t __span_aligned_alloc = aligned_alloc;
@ -60,13 +55,18 @@ span_aligned_alloc_t __span_aligned_alloc = aligned_alloc;
span_aligned_alloc_t __span_aligned_alloc = memalign;
#elif defined(HAVE_POSIX_MEMALIGN)
span_aligned_alloc_t __span_aligned_alloc = fake_posix_memalign;
static void *fake_posix_memalign(size_t alignment, size_t size);
#else
span_aligned_alloc_t __span_aligned_alloc = fake_aligned_alloc;
#endif
span_realloc_t __span_realloc = realloc;
span_free_t __span_free = free;
#if defined(HAVE_POSIX_MEMALIGN)
static void *fake_aligned_alloc(size_t alignment, size_t size);
#if defined(HAVE_ALIGNED_ALLOC)
#elif defined(HAVE_MEMALIGN)
#elif defined(HAVE_POSIX_MEMALIGN)
static void *fake_posix_memalign(size_t alignment, size_t size)
{
void *ptr;

View File

@ -35,6 +35,7 @@
#include <assert.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/bit_operations.h"
#include "spandsp/async.h"
@ -174,7 +175,7 @@ SPAN_DECLARE(async_rx_state_t *) async_rx_init(async_rx_state_t *s,
{
if (s == NULL)
{
if ((s = (async_rx_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (async_rx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
s->data_bits = data_bits;
@ -203,7 +204,7 @@ SPAN_DECLARE(int) async_rx_release(async_rx_state_t *s)
SPAN_DECLARE(int) async_rx_free(async_rx_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -274,7 +275,7 @@ SPAN_DECLARE(async_tx_state_t *) async_tx_init(async_tx_state_t *s,
{
if (s == NULL)
{
if ((s = (async_tx_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (async_tx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
/* We have a use_v14 parameter for completeness, but right now V.14 only
@ -304,7 +305,7 @@ SPAN_DECLARE(int) async_tx_release(async_tx_state_t *s)
SPAN_DECLARE(int) async_tx_free(async_tx_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -46,6 +46,7 @@
#include <assert.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/queue.h"
#include "spandsp/power_meter.h"
@ -379,7 +380,7 @@ SPAN_DECLARE(void) at_reset_call_info(at_state_t *s)
for (call_id = s->call_id; call_id; call_id = next)
{
next = call_id->next;
free(call_id);
span_free(call_id);
}
s->call_id = NULL;
s->rings_indicated = 0;
@ -392,8 +393,8 @@ SPAN_DECLARE(void) at_set_call_info(at_state_t *s, char const *id, char const *v
at_call_id_t *new_call_id;
at_call_id_t *call_id;
/* TODO: We should really not merely ignore a failure to malloc */
if ((new_call_id = (at_call_id_t *) malloc(sizeof(*new_call_id))) == NULL)
/* TODO: We should really not merely ignore a failure to allocate */
if ((new_call_id = (at_call_id_t *) span_alloc(sizeof(*new_call_id))) == NULL)
return;
call_id = s->call_id;
/* If these strdups fail its pretty harmless. We just appear to not
@ -752,7 +753,7 @@ static int parse_string_out(at_state_t *s, const char **t, char **target, const
default:
/* Set value */
if (*target)
free(*target);
span_free(*target);
/* If this strdup fails, it should be harmless */
*target = strdup(*t);
break;
@ -5590,7 +5591,7 @@ SPAN_DECLARE(at_state_t *) at_init(at_state_t *s,
{
if (s == NULL)
{
if ((s = (at_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (at_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, '\0', sizeof(*s));
@ -5615,7 +5616,7 @@ SPAN_DECLARE(int) at_release(at_state_t *s)
{
at_reset_call_info(s);
if (s->local_id)
free(s->local_id);
span_free(s->local_id);
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -5625,7 +5626,7 @@ SPAN_DECLARE(int) at_free(at_state_t *s)
int ret;
ret = at_release(s);
free(s);
span_free(s);
return ret;
}
/*- End of function --------------------------------------------------------*/

View File

@ -55,6 +55,7 @@
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/saturated.h"
#include "spandsp/awgn.h"
@ -100,7 +101,7 @@ SPAN_DECLARE(awgn_state_t *) awgn_init_dbov(awgn_state_t *s, int idum, float lev
if (s == NULL)
{
if ((s = (awgn_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (awgn_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
if (idum < 0)
@ -140,7 +141,7 @@ SPAN_DECLARE(int) awgn_release(awgn_state_t *s)
SPAN_DECLARE(int) awgn_free(awgn_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -43,6 +43,7 @@
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/fast_convert.h"
#include "spandsp/queue.h"
@ -325,7 +326,7 @@ SPAN_DECLARE(bell_mf_tx_state_t *) bell_mf_tx_init(bell_mf_tx_state_t *s)
{
if (s == NULL)
{
if ((s = (bell_mf_tx_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (bell_mf_tx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -348,7 +349,7 @@ SPAN_DECLARE(int) bell_mf_tx_release(bell_mf_tx_state_t *s)
SPAN_DECLARE(int) bell_mf_tx_free(bell_mf_tx_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -397,7 +398,7 @@ SPAN_DECLARE(r2_mf_tx_state_t *) r2_mf_tx_init(r2_mf_tx_state_t *s, int fwd)
if (s == NULL)
{
if ((s = (r2_mf_tx_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (r2_mf_tx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -451,7 +452,7 @@ SPAN_DECLARE(int) r2_mf_tx_release(r2_mf_tx_state_t *s)
SPAN_DECLARE(int) r2_mf_tx_free(r2_mf_tx_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -633,7 +634,7 @@ SPAN_DECLARE(bell_mf_rx_state_t *) bell_mf_rx_init(bell_mf_rx_state_t *s,
if (s == NULL)
{
if ((s = (bell_mf_rx_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (bell_mf_rx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -671,7 +672,7 @@ SPAN_DECLARE(int) bell_mf_rx_release(bell_mf_rx_state_t *s)
SPAN_DECLARE(int) bell_mf_rx_free(bell_mf_rx_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -813,7 +814,7 @@ SPAN_DECLARE(r2_mf_rx_state_t *) r2_mf_rx_init(r2_mf_rx_state_t *s,
if (s == NULL)
{
if ((s = (r2_mf_rx_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (r2_mf_rx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -855,7 +856,7 @@ SPAN_DECLARE(int) r2_mf_rx_release(r2_mf_rx_state_t *s)
SPAN_DECLARE(int) r2_mf_rx_free(r2_mf_rx_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -35,6 +35,7 @@
#include <time.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/async.h"
#include "spandsp/bert.h"
@ -350,7 +351,7 @@ SPAN_DECLARE(bert_state_t *) bert_init(bert_state_t *s, int limit, int pattern,
if (s == NULL)
{
if ((s = (bert_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (bert_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -503,7 +504,7 @@ SPAN_DECLARE(int) bert_release(bert_state_t *s)
SPAN_DECLARE(int) bert_free(bert_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -35,6 +35,7 @@
#include <assert.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/bitstream.h"
#include "spandsp/private/bitstream.h"
@ -132,7 +133,7 @@ SPAN_DECLARE(bitstream_state_t *) bitstream_init(bitstream_state_t *s, int lsb_f
{
if (s == NULL)
{
if ((s = (bitstream_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (bitstream_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
s->bitstream = 0;
@ -151,7 +152,7 @@ SPAN_DECLARE(int) bitstream_release(bitstream_state_t *s)
SPAN_DECLARE(int) bitstream_free(bitstream_state_t *s)
{
if (s)
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -32,6 +32,7 @@
#include <inttypes.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/complex.h"
#include "spandsp/complex_filters.h"
@ -40,7 +41,7 @@ SPAN_DECLARE(filter_t *) filter_create(fspec_t *fs)
int i;
filter_t *fi;
if ((fi = (filter_t *) malloc(sizeof(*fi) + sizeof(float)*(fs->np + 1))))
if ((fi = (filter_t *) span_alloc(sizeof(*fi) + sizeof(float)*(fs->np + 1))))
{
fi->fs = fs;
fi->sum = 0.0;
@ -56,7 +57,7 @@ SPAN_DECLARE(filter_t *) filter_create(fspec_t *fs)
SPAN_DECLARE(void) filter_delete(filter_t *fi)
{
if (fi)
free(fi);
span_free(fi);
}
/*- End of function --------------------------------------------------------*/
@ -70,17 +71,17 @@ SPAN_DECLARE(cfilter_t *) cfilter_create(fspec_t *fs)
{
cfilter_t *cfi;
if ((cfi = (cfilter_t *) malloc(sizeof(*cfi))))
if ((cfi = (cfilter_t *) span_alloc(sizeof(*cfi))))
{
if ((cfi->ref = filter_create(fs)) == NULL)
{
free(cfi);
span_free(cfi);
return NULL;
}
if ((cfi->imf = filter_create(fs)) == NULL)
{
free(cfi->ref);
free(cfi);
span_free(cfi->ref);
span_free(cfi);
return NULL;
}
}

View File

@ -43,6 +43,7 @@
#include <limits.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/fast_convert.h"
#include "spandsp/queue.h"
@ -413,7 +414,7 @@ SPAN_DECLARE(dtmf_rx_state_t *) dtmf_rx_init(dtmf_rx_state_t *s,
if (s == NULL)
{
if ((s = (dtmf_rx_state_t *) malloc(sizeof (*s))) == NULL)
if ((s = (dtmf_rx_state_t *) span_alloc(sizeof (*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -466,7 +467,7 @@ SPAN_DECLARE(int) dtmf_rx_release(dtmf_rx_state_t *s)
SPAN_DECLARE(int) dtmf_rx_free(dtmf_rx_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -578,7 +579,7 @@ SPAN_DECLARE(dtmf_tx_state_t *) dtmf_tx_init(dtmf_tx_state_t *s,
{
if (s == NULL)
{
if ((s = (dtmf_tx_state_t *) malloc(sizeof (*s))) == NULL)
if ((s = (dtmf_tx_state_t *) span_alloc(sizeof (*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -603,7 +604,7 @@ SPAN_DECLARE(int) dtmf_tx_release(dtmf_tx_state_t *s)
SPAN_DECLARE(int) dtmf_tx_free(dtmf_tx_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -93,6 +93,7 @@
#include <stdio.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/logging.h"
#include "spandsp/saturated.h"
@ -244,26 +245,26 @@ SPAN_DECLARE(echo_can_state_t *) echo_can_init(int len, int adaption_mode)
int i;
int j;
if ((ec = (echo_can_state_t *) malloc(sizeof(*ec))) == NULL)
if ((ec = (echo_can_state_t *) span_alloc(sizeof(*ec))) == NULL)
return NULL;
memset(ec, 0, sizeof(*ec));
ec->taps = len;
ec->curr_pos = ec->taps - 1;
ec->tap_mask = ec->taps - 1;
if ((ec->fir_taps32 = (int32_t *) malloc(ec->taps*sizeof(int32_t))) == NULL)
if ((ec->fir_taps32 = (int32_t *) span_alloc(ec->taps*sizeof(int32_t))) == NULL)
{
free(ec);
span_free(ec);
return NULL;
}
memset(ec->fir_taps32, 0, ec->taps*sizeof(int32_t));
for (i = 0; i < 4; i++)
{
if ((ec->fir_taps16[i] = (int16_t *) malloc(ec->taps*sizeof(int16_t))) == NULL)
if ((ec->fir_taps16[i] = (int16_t *) span_alloc(ec->taps*sizeof(int16_t))) == NULL)
{
for (j = 0; j < i; j++)
free(ec->fir_taps16[j]);
free(ec->fir_taps32);
free(ec);
span_free(ec->fir_taps16[j]);
span_free(ec->fir_taps32);
span_free(ec);
return NULL;
}
memset(ec->fir_taps16[i], 0, ec->taps*sizeof(int16_t));
@ -294,10 +295,10 @@ SPAN_DECLARE(int) echo_can_free(echo_can_state_t *ec)
int i;
fir16_free(&ec->fir_state);
free(ec->fir_taps32);
span_free(ec->fir_taps32);
for (i = 0; i < 4; i++)
free(ec->fir_taps16[i]);
free(ec);
span_free(ec->fir_taps16[i]);
span_free(ec);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -50,6 +50,7 @@
#include <tiffio.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/queue.h"
#include "spandsp/dc_restore.h"
@ -470,7 +471,7 @@ SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party)
if (s == NULL)
{
if ((s = (fax_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (fax_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -525,7 +526,7 @@ SPAN_DECLARE(int) fax_release(fax_state_t *s)
SPAN_DECLARE(int) fax_free(fax_state_t *s)
{
t30_release(&s->t30);
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -48,6 +48,7 @@
#endif
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/bit_operations.h"
#include "spandsp/dc_restore.h"
@ -503,7 +504,7 @@ SPAN_DECLARE(fax_modems_state_t *) fax_modems_init(fax_modems_state_t *s,
{
if (s == NULL)
{
if ((s = (fax_modems_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (fax_modems_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
/*endif*/
@ -562,7 +563,7 @@ SPAN_DECLARE(int) fax_modems_release(fax_modems_state_t *s)
SPAN_DECLARE(int) fax_modems_free(fax_modems_state_t *s)
{
if (s)
free(s);
span_free(s);
/*endif*/
return 0;
}

View File

@ -35,6 +35,7 @@
#include <assert.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/bit_operations.h"
#include "spandsp/g711.h"
#include "spandsp/private/g711.h"
@ -171,7 +172,7 @@ SPAN_DECLARE(g711_state_t *) g711_init(g711_state_t *s, int mode)
{
if (s == NULL)
{
if ((s = (g711_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (g711_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
s->mode = mode;
@ -187,7 +188,7 @@ SPAN_DECLARE(int) g711_release(g711_state_t *s)
SPAN_DECLARE(int) g711_free(g711_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -41,6 +41,7 @@
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/saturated.h"
#include "spandsp/vector_int.h"
@ -251,7 +252,7 @@ SPAN_DECLARE(g722_decode_state_t *) g722_decode_init(g722_decode_state_t *s, int
{
if (s == NULL)
{
if ((s = (g722_decode_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (g722_decode_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -281,7 +282,7 @@ SPAN_DECLARE(int) g722_decode_release(g722_decode_state_t *s)
SPAN_DECLARE(int) g722_decode_free(g722_decode_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -432,7 +433,7 @@ SPAN_DECLARE(g722_encode_state_t *) g722_encode_init(g722_encode_state_t *s, int
{
if (s == NULL)
{
if ((s = (g722_encode_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (g722_encode_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -462,7 +463,7 @@ SPAN_DECLARE(int) g722_encode_release(g722_encode_state_t *s)
SPAN_DECLARE(int) g722_encode_free(g722_encode_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -67,6 +67,7 @@
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/bitstream.h"
#include "spandsp/bit_operations.h"
#include "spandsp/g711.h"
@ -1002,7 +1003,7 @@ SPAN_DECLARE(g726_state_t *) g726_init(g726_state_t *s, int bit_rate, int ext_co
return NULL;
if (s == NULL)
{
if ((s = (g726_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (g726_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
s->yl = 34816;
@ -1062,7 +1063,7 @@ SPAN_DECLARE(int) g726_release(g726_state_t *s)
SPAN_DECLARE(int) g726_free(g726_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -45,6 +45,7 @@
#include <memory.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/bitstream.h"
#include "spandsp/saturated.h"
@ -115,7 +116,7 @@ SPAN_DECLARE(gsm0610_state_t *) gsm0610_init(gsm0610_state_t *s, int packing)
{
if (s == NULL)
{
if ((s = (gsm0610_state_t *) malloc(sizeof (*s))) == NULL)
if ((s = (gsm0610_state_t *) span_alloc(sizeof (*s))) == NULL)
return NULL;
/*endif*/
}
@ -136,7 +137,7 @@ SPAN_DECLARE(int) gsm0610_release(gsm0610_state_t *s)
SPAN_DECLARE(int) gsm0610_free(gsm0610_state_t *s)
{
if (s)
free(s);
span_free(s);
/*endif*/
return 0;
}

View File

@ -42,6 +42,7 @@
#include <time.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/private/logging.h"
@ -229,7 +230,7 @@ SPAN_DECLARE(logging_state_t *) span_log_init(logging_state_t *s, int level, con
{
if (s == NULL)
{
if ((s = (logging_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (logging_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
s->span_message = __span_message;
@ -252,7 +253,7 @@ SPAN_DECLARE(int) span_log_release(logging_state_t *s)
SPAN_DECLARE(int) span_log_free(logging_state_t *s)
{
if (s)
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -44,6 +44,7 @@
#include <memory.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/lpc10.h"
#include "spandsp/private/lpc10.h"
@ -1016,7 +1017,7 @@ SPAN_DECLARE(lpc10_decode_state_t *) lpc10_decode_init(lpc10_decode_state_t *s,
if (s == NULL)
{
if ((s = (lpc10_decode_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (lpc10_decode_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
@ -1084,7 +1085,7 @@ SPAN_DECLARE(int) lpc10_decode_release(lpc10_decode_state_t *s)
SPAN_DECLARE(int) lpc10_decode_free(lpc10_decode_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -44,6 +44,7 @@
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/lpc10.h"
#include "spandsp/private/lpc10.h"
@ -269,7 +270,7 @@ SPAN_DECLARE(lpc10_encode_state_t *) lpc10_encode_init(lpc10_encode_state_t *s,
if (s == NULL)
{
if ((s = (lpc10_encode_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (lpc10_encode_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
@ -367,7 +368,7 @@ SPAN_DECLARE(int) lpc10_encode_release(lpc10_encode_state_t *s)
SPAN_DECLARE(int) lpc10_encode_free(lpc10_encode_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -57,6 +57,7 @@
#include <stdio.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/logging.h"
#include "spandsp/complex.h"
@ -258,7 +259,7 @@ SPAN_DECLARE(modem_connect_tones_tx_state_t *) modem_connect_tones_tx_init(modem
alloced = FALSE;
if (s == NULL)
{
if ((s = (modem_connect_tones_tx_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (modem_connect_tones_tx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
alloced = TRUE;
}
@ -341,7 +342,7 @@ SPAN_DECLARE(modem_connect_tones_tx_state_t *) modem_connect_tones_tx_init(modem
break;
default:
if (alloced)
free(s);
span_free(s);
return NULL;
}
return s;
@ -356,7 +357,7 @@ SPAN_DECLARE(int) modem_connect_tones_tx_release(modem_connect_tones_tx_state_t
SPAN_DECLARE(int) modem_connect_tones_tx_free(modem_connect_tones_tx_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -716,7 +717,7 @@ SPAN_DECLARE(modem_connect_tones_rx_state_t *) modem_connect_tones_rx_init(modem
{
if (s == NULL)
{
if ((s = (modem_connect_tones_rx_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (modem_connect_tones_rx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
@ -765,7 +766,7 @@ SPAN_DECLARE(int) modem_connect_tones_rx_release(modem_connect_tones_rx_state_t
SPAN_DECLARE(int) modem_connect_tones_rx_free(modem_connect_tones_rx_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -47,6 +47,7 @@
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/bit_operations.h"
#include "spandsp/dc_restore.h"
#include "spandsp/modem_echo.h"
@ -66,29 +67,29 @@ SPAN_DECLARE(modem_echo_can_state_t *) modem_echo_can_init(int len)
{
modem_echo_can_state_t *ec;
if ((ec = (modem_echo_can_state_t *) malloc(sizeof(*ec))) == NULL)
if ((ec = (modem_echo_can_state_t *) span_alloc(sizeof(*ec))) == NULL)
return NULL;
memset(ec, 0, sizeof(*ec));
ec->taps = len;
ec->curr_pos = ec->taps - 1;
if ((ec->fir_taps32 = (int32_t *) malloc(ec->taps*sizeof(int32_t))) == NULL)
if ((ec->fir_taps32 = (int32_t *) span_alloc(ec->taps*sizeof(int32_t))) == NULL)
{
free(ec);
return NULL;
}
memset(ec->fir_taps32, 0, ec->taps*sizeof(int32_t));
if ((ec->fir_taps16 = (int16_t *) malloc(ec->taps*sizeof(int16_t))) == NULL)
if ((ec->fir_taps16 = (int16_t *) span_alloc(ec->taps*sizeof(int16_t))) == NULL)
{
free(ec->fir_taps32);
free(ec);
span_free(ec->fir_taps32);
span_free(ec);
return NULL;
}
memset(ec->fir_taps16, 0, ec->taps*sizeof(int16_t));
if (fir16_create(&ec->fir_state, ec->fir_taps16, ec->taps) == NULL)
{
free(ec->fir_taps16);
free(ec->fir_taps32);
free(ec);
span_free(ec->fir_taps16);
span_free(ec->fir_taps32);
span_free(ec);
return NULL;
}
return ec;

View File

@ -43,6 +43,7 @@
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/saturated.h"
#include "spandsp/noise.h"
@ -84,7 +85,7 @@ SPAN_DECLARE(noise_state_t *) noise_init_dbov(noise_state_t *s, int seed, float
if (s == NULL)
{
if ((s = (noise_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (noise_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -121,7 +122,7 @@ SPAN_DECLARE(int) noise_release(noise_state_t *s)
SPAN_DECLARE(int) noise_free(noise_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -39,6 +39,7 @@
#include <string.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/oki_adpcm.h"
#include "spandsp/private/oki_adpcm.h"
@ -246,7 +247,7 @@ SPAN_DECLARE(oki_adpcm_state_t *) oki_adpcm_init(oki_adpcm_state_t *s, int bit_r
return NULL;
if (s == NULL)
{
if ((s = (oki_adpcm_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (oki_adpcm_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -264,7 +265,7 @@ SPAN_DECLARE(int) oki_adpcm_release(oki_adpcm_state_t *s)
SPAN_DECLARE(int) oki_adpcm_free(oki_adpcm_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -41,6 +41,7 @@
#include <limits.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/playout.h"
static playout_frame_t *queue_get(playout_state_t *s, timestamp_t sender_stamp)
@ -236,7 +237,7 @@ SPAN_DECLARE(int) playout_put(playout_state_t *s, void *data, int type, timestam
}
else
{
if ((frame = (playout_frame_t *) malloc(sizeof(*frame))) == NULL)
if ((frame = (playout_frame_t *) span_alloc(sizeof(*frame))) == NULL)
return PLAYOUT_ERROR;
}
@ -312,7 +313,7 @@ SPAN_DECLARE(void) playout_restart(playout_state_t *s, int min_length, int max_l
for (frame = s->free_frames; frame; frame = next)
{
next = frame->later;
free(frame);
span_free(frame);
}
memset(s, 0, sizeof(*s));
@ -332,7 +333,7 @@ SPAN_DECLARE(playout_state_t *) playout_init(int min_length, int max_length)
{
playout_state_t *s;
if ((s = (playout_state_t *) malloc(sizeof(playout_state_t))) == NULL)
if ((s = (playout_state_t *) span_alloc(sizeof(playout_state_t))) == NULL)
return NULL;
memset(s, 0, sizeof(*s));
playout_restart(s, min_length, max_length);
@ -350,13 +351,13 @@ SPAN_DECLARE(int) playout_release(playout_state_t *s)
for (frame = s->first_frame; frame; frame = next)
{
next = frame->later;
free(frame);
span_free(frame);
}
/* Free all the frames on the free list */
for (frame = s->free_frames; frame; frame = next)
{
next = frame->later;
free(frame);
span_free(frame);
}
return 0;
}
@ -368,7 +369,7 @@ SPAN_DECLARE(int) playout_free(playout_state_t *s)
{
playout_release(s);
/* Finally, free ourselves! */
free(s);
span_free(s);
}
return 0;
}

View File

@ -43,6 +43,7 @@
#include <limits.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/saturated.h"
#include "spandsp/plc.h"
@ -234,7 +235,7 @@ SPAN_DECLARE(plc_state_t *) plc_init(plc_state_t *s)
{
if (s == NULL)
{
if ((s = (plc_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (plc_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -251,7 +252,7 @@ SPAN_DECLARE(int) plc_release(plc_state_t *s)
SPAN_DECLARE(int) plc_free(plc_state_t *s)
{
if (s)
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -45,13 +45,14 @@
#include <assert.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/power_meter.h"
SPAN_DECLARE(power_meter_t *) power_meter_init(power_meter_t *s, int shift)
{
if (s == NULL)
{
if ((s = (power_meter_t *) malloc(sizeof(*s))) == NULL)
if ((s = (power_meter_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
s->shift = shift;
@ -69,7 +70,7 @@ SPAN_DECLARE(int) power_meter_release(power_meter_t *s)
SPAN_DECLARE(int) power_meter_free(power_meter_t *s)
{
if (s)
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -181,7 +182,7 @@ SPAN_DECLARE(power_surge_detector_state_t *) power_surge_detector_init(power_sur
if (s == NULL)
{
if ((s = (power_surge_detector_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (power_surge_detector_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -205,7 +206,7 @@ SPAN_DECLARE(int) power_surge_detector_release(power_surge_detector_state_t *s)
SPAN_DECLARE(int) power_surge_detector_free(power_surge_detector_state_t *s)
{
if (s)
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -39,6 +39,7 @@
#define SPANDSP_FULLY_DEFINE_QUEUE_STATE_T
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/queue.h"
#include "spandsp/private/queue.h"
@ -395,7 +396,7 @@ SPAN_DECLARE(queue_state_t *) queue_init(queue_state_t *s, int len, int flags)
{
if (s == NULL)
{
if ((s = (queue_state_t *) malloc(sizeof(*s) + len + 1)) == NULL)
if ((s = (queue_state_t *) span_alloc(sizeof(*s) + len + 1)) == NULL)
return NULL;
}
s->iptr =
@ -414,7 +415,7 @@ SPAN_DECLARE(int) queue_release(queue_state_t *s)
SPAN_DECLARE(int) queue_free(queue_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -33,6 +33,7 @@
#include <memory.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/schedule.h"
@ -53,7 +54,7 @@ SPAN_DECLARE(int) span_schedule_event(span_sched_state_t *s, int us, span_sched_
if (i >= s->allocated)
{
s->allocated += 5;
s->sched = (span_sched_t *) realloc(s->sched, sizeof(span_sched_t)*s->allocated);
s->sched = (span_sched_t *) span_realloc(s->sched, sizeof(span_sched_t)*s->allocated);
}
/*endif*/
if (i >= s->max_to_date)
@ -141,7 +142,7 @@ SPAN_DECLARE(int) span_schedule_release(span_sched_state_t *s)
{
if (s->sched)
{
free(s->sched);
span_free(s->sched);
s->sched = NULL;
}
return 0;
@ -152,7 +153,7 @@ SPAN_DECLARE(int) span_schedule_free(span_sched_state_t *s)
{
span_schedule_release(s);
if (s)
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -44,6 +44,7 @@
#include <limits.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/saturated.h"
#include "spandsp/vector_int.h"
@ -325,7 +326,7 @@ SPAN_DECLARE(sig_tone_tx_state_t *) sig_tone_tx_init(sig_tone_tx_state_t *s, int
if (s == NULL)
{
if ((s = (sig_tone_tx_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (sig_tone_tx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -357,7 +358,7 @@ SPAN_DECLARE(int) sig_tone_tx_release(sig_tone_tx_state_t *s)
SPAN_DECLARE(int) sig_tone_tx_free(sig_tone_tx_state_t *s)
{
if (s)
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -641,7 +642,7 @@ SPAN_DECLARE(sig_tone_rx_state_t *) sig_tone_rx_init(sig_tone_rx_state_t *s, int
if (s == NULL)
{
if ((s = (sig_tone_rx_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (sig_tone_rx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -685,7 +686,7 @@ SPAN_DECLARE(int) sig_tone_rx_release(sig_tone_rx_state_t *s)
SPAN_DECLARE(int) sig_tone_rx_free(sig_tone_rx_state_t *s)
{
if (s)
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -45,6 +45,7 @@
#include <limits.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/async.h"
#include "spandsp/silence_gen.h"
@ -119,7 +120,7 @@ SPAN_DECLARE(silence_gen_state_t *) silence_gen_init(silence_gen_state_t *s, int
{
if (s == NULL)
{
if ((s = (silence_gen_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (silence_gen_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -137,7 +138,7 @@ SPAN_DECLARE(int) silence_gen_release(silence_gen_state_t *s)
SPAN_DECLARE(int) silence_gen_free(silence_gen_state_t *s)
{
if (s)
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -45,6 +45,7 @@
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/complex.h"
#include "spandsp/vector_float.h"
@ -95,7 +96,7 @@ static int add_super_tone_freq(super_tone_rx_descriptor_t *desc, int freq)
desc->pitches[i][1] = desc->monitored_frequencies;
if (desc->monitored_frequencies%5 == 0)
{
desc->desc = (goertzel_descriptor_t *) realloc(desc->desc, (desc->monitored_frequencies + 5)*sizeof(goertzel_descriptor_t));
desc->desc = (goertzel_descriptor_t *) span_realloc(desc->desc, (desc->monitored_frequencies + 5)*sizeof(goertzel_descriptor_t));
}
make_goertzel_descriptor(&desc->desc[desc->monitored_frequencies++], (float) freq, SUPER_TONE_BINS);
desc->used_frequencies++;
@ -107,8 +108,8 @@ SPAN_DECLARE(int) super_tone_rx_add_tone(super_tone_rx_descriptor_t *desc)
{
if (desc->tones%5 == 0)
{
desc->tone_list = (super_tone_rx_segment_t **) realloc(desc->tone_list, (desc->tones + 5)*sizeof(super_tone_rx_segment_t *));
desc->tone_segs = (int *) realloc(desc->tone_segs, (desc->tones + 5)*sizeof(int));
desc->tone_list = (super_tone_rx_segment_t **) span_realloc(desc->tone_list, (desc->tones + 5)*sizeof(super_tone_rx_segment_t *));
desc->tone_segs = (int *) span_realloc(desc->tone_segs, (desc->tones + 5)*sizeof(int));
}
desc->tone_list[desc->tones] = NULL;
desc->tone_segs[desc->tones] = 0;
@ -129,7 +130,7 @@ SPAN_DECLARE(int) super_tone_rx_add_element(super_tone_rx_descriptor_t *desc,
step = desc->tone_segs[tone];
if (step%5 == 0)
{
desc->tone_list[tone] = (super_tone_rx_segment_t *) realloc(desc->tone_list[tone], (step + 5)*sizeof(super_tone_rx_segment_t));
desc->tone_list[tone] = (super_tone_rx_segment_t *) span_realloc(desc->tone_list[tone], (step + 5)*sizeof(super_tone_rx_segment_t));
}
desc->tone_list[tone][step].f1 = add_super_tone_freq(desc, f1);
desc->tone_list[tone][step].f2 = add_super_tone_freq(desc, f2);
@ -199,7 +200,7 @@ SPAN_DECLARE(super_tone_rx_descriptor_t *) super_tone_rx_make_descriptor(super_t
{
if (desc == NULL)
{
if ((desc = (super_tone_rx_descriptor_t *) malloc(sizeof(*desc))) == NULL)
if ((desc = (super_tone_rx_descriptor_t *) span_alloc(sizeof(*desc))) == NULL)
return NULL;
}
desc->tone_list = NULL;
@ -222,15 +223,15 @@ SPAN_DECLARE(int) super_tone_rx_free_descriptor(super_tone_rx_descriptor_t *desc
for (i = 0; i < desc->tones; i++)
{
if (desc->tone_list[i])
free(desc->tone_list[i]);
span_free(desc->tone_list[i]);
}
if (desc->tone_list)
free(desc->tone_list);
span_free(desc->tone_list);
if (desc->tone_segs)
free(desc->tone_segs);
span_free(desc->tone_segs);
if (desc->desc)
free(desc->desc);
free(desc);
span_free(desc->desc);
span_free(desc);
}
return 0;
}
@ -265,7 +266,7 @@ SPAN_DECLARE(super_tone_rx_state_t *) super_tone_rx_init(super_tone_rx_state_t *
return NULL;
if (s == NULL)
{
if ((s = (super_tone_rx_state_t *) malloc(sizeof(*s) + desc->monitored_frequencies*sizeof(goertzel_state_t))) == NULL)
if ((s = (super_tone_rx_state_t *) span_alloc(sizeof(*s) + desc->monitored_frequencies*sizeof(goertzel_state_t))) == NULL)
return NULL;
}
@ -301,7 +302,7 @@ SPAN_DECLARE(int) super_tone_rx_release(super_tone_rx_state_t *s)
SPAN_DECLARE(int) super_tone_rx_free(super_tone_rx_state_t *s)
{
if (s)
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -45,6 +45,7 @@
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/complex.h"
#include "spandsp/dds.h"
@ -78,7 +79,7 @@ SPAN_DECLARE(super_tone_tx_step_t *) super_tone_tx_make_step(super_tone_tx_step_
{
if (s == NULL)
{
if ((s = (super_tone_tx_step_t *) malloc(sizeof(*s))) == NULL)
if ((s = (super_tone_tx_step_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
if (f1 >= 1.0f)
@ -121,7 +122,7 @@ SPAN_DECLARE(int) super_tone_tx_free_tone(super_tone_tx_step_t *s)
super_tone_tx_free_tone(s->nest);
t = s;
s = s->next;
free(t);
span_free(t);
}
return 0;
}
@ -133,7 +134,7 @@ SPAN_DECLARE(super_tone_tx_state_t *) super_tone_tx_init(super_tone_tx_state_t *
return NULL;
if (s == NULL)
{
if ((s = (super_tone_tx_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (super_tone_tx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -155,7 +156,7 @@ SPAN_DECLARE(int) super_tone_tx_release(super_tone_tx_state_t *s)
SPAN_DECLARE(int) super_tone_tx_free(super_tone_tx_state_t *s)
{
if (s)
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -42,6 +42,7 @@
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/complex.h"
#include "spandsp/vector_float.h"
@ -59,7 +60,7 @@ SPAN_DECLARE(swept_tone_state_t *) swept_tone_init(swept_tone_state_t *s, float
{
if (s == NULL)
{
if ((s = (swept_tone_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (swept_tone_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -119,7 +120,7 @@ SPAN_DECLARE(int) swept_tone_release(swept_tone_state_t *s)
SPAN_DECLARE(int) swept_tone_free(swept_tone_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -45,6 +45,7 @@
#include <tiffio.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/bit_operations.h"
#include "spandsp/queue.h"
@ -277,8 +278,8 @@ SPAN_DECLARE(const char *) t30_get_rx_password(t30_state_t *s)
SPAN_DECLARE(int) t30_set_tx_nsf(t30_state_t *s, const uint8_t *nsf, int len)
{
if (s->tx_info.nsf)
free(s->tx_info.nsf);
if (nsf && len > 0 && (s->tx_info.nsf = malloc(len + 3)))
span_free(s->tx_info.nsf);
if (nsf && len > 0 && (s->tx_info.nsf = span_alloc(len + 3)))
{
memcpy(s->tx_info.nsf + 3, nsf, len);
s->tx_info.nsf_len = len;
@ -311,8 +312,8 @@ SPAN_DECLARE(size_t) t30_get_rx_nsf(t30_state_t *s, const uint8_t *nsf[])
SPAN_DECLARE(int) t30_set_tx_nsc(t30_state_t *s, const uint8_t *nsc, int len)
{
if (s->tx_info.nsc)
free(s->tx_info.nsc);
if (nsc && len > 0 && (s->tx_info.nsc = malloc(len + 3)))
span_free(s->tx_info.nsc);
if (nsc && len > 0 && (s->tx_info.nsc = span_alloc(len + 3)))
{
memcpy(s->tx_info.nsc + 3, nsc, len);
s->tx_info.nsc_len = len;
@ -345,8 +346,8 @@ SPAN_DECLARE(size_t) t30_get_rx_nsc(t30_state_t *s, const uint8_t *nsc[])
SPAN_DECLARE(int) t30_set_tx_nss(t30_state_t *s, const uint8_t *nss, int len)
{
if (s->tx_info.nss)
free(s->tx_info.nss);
if (nss && len > 0 && (s->tx_info.nss = malloc(len + 3)))
span_free(s->tx_info.nss);
if (nss && len > 0 && (s->tx_info.nss = span_alloc(len + 3)))
{
memcpy(s->tx_info.nss + 3, nss, len);
s->tx_info.nss_len = len;
@ -379,7 +380,7 @@ SPAN_DECLARE(size_t) t30_get_rx_nss(t30_state_t *s, const uint8_t *nss[])
SPAN_DECLARE(int) t30_set_tx_tsa(t30_state_t *s, int type, const char *address, int len)
{
if (s->tx_info.tsa)
free(s->tx_info.tsa);
span_free(s->tx_info.tsa);
if (address == NULL || len == 0)
{
s->tx_info.tsa = NULL;
@ -389,7 +390,7 @@ SPAN_DECLARE(int) t30_set_tx_tsa(t30_state_t *s, int type, const char *address,
s->tx_info.tsa_type = type;
if (len < 0)
len = strlen(address);
if ((s->tx_info.tsa = malloc(len)))
if ((s->tx_info.tsa = span_alloc(len)))
{
memcpy(s->tx_info.tsa, address, len);
s->tx_info.tsa_len = len;
@ -421,7 +422,7 @@ SPAN_DECLARE(size_t) t30_get_rx_tsa(t30_state_t *s, int *type, const char *addre
SPAN_DECLARE(int) t30_set_tx_ira(t30_state_t *s, int type, const char *address, int len)
{
if (s->tx_info.ira)
free(s->tx_info.ira);
span_free(s->tx_info.ira);
if (address == NULL)
{
s->tx_info.ira = NULL;
@ -455,7 +456,7 @@ SPAN_DECLARE(size_t) t30_get_rx_ira(t30_state_t *s, int *type, const char *addre
SPAN_DECLARE(int) t30_set_tx_cia(t30_state_t *s, int type, const char *address, int len)
{
if (s->tx_info.cia)
free(s->tx_info.cia);
span_free(s->tx_info.cia);
if (address == NULL)
{
s->tx_info.cia = NULL;
@ -489,7 +490,7 @@ SPAN_DECLARE(size_t) t30_get_rx_cia(t30_state_t *s, int *type, const char *addre
SPAN_DECLARE(int) t30_set_tx_isp(t30_state_t *s, int type, const char *address, int len)
{
if (s->tx_info.isp)
free(s->tx_info.isp);
span_free(s->tx_info.isp);
if (address == NULL)
{
s->tx_info.isp = NULL;
@ -523,7 +524,7 @@ SPAN_DECLARE(size_t) t30_get_rx_isp(t30_state_t *s, int *type, const char *addre
SPAN_DECLARE(int) t30_set_tx_csa(t30_state_t *s, int type, const char *address, int len)
{
if (s->tx_info.csa)
free(s->tx_info.csa);
span_free(s->tx_info.csa);
if (address == NULL)
{
s->tx_info.csa = NULL;

View File

@ -35,6 +35,7 @@
#include <string.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/t81_t82_arith_coding.h"
#include "spandsp/private/t81_t82_arith_coding.h"
@ -341,7 +342,7 @@ SPAN_DECLARE(t81_t82_arith_encode_state_t *) t81_t82_arith_encode_init(t81_t82_a
{
if (s == NULL)
{
if ((s = (t81_t82_arith_encode_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (t81_t82_arith_encode_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -364,7 +365,7 @@ SPAN_DECLARE(int) t81_t82_arith_encode_free(t81_t82_arith_encode_state_t *s)
int ret;
ret = t81_t82_arith_encode_release(s);
free(s);
span_free(s);
return ret;
}
/*- End of function --------------------------------------------------------*/
@ -481,7 +482,7 @@ SPAN_DECLARE(t81_t82_arith_decode_state_t *) t81_t82_arith_decode_init(t81_t82_a
{
if (s == NULL)
{
if ((s = (t81_t82_arith_decode_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (t81_t82_arith_decode_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -502,7 +503,7 @@ SPAN_DECLARE(int) t81_t82_arith_decode_free(t81_t82_arith_decode_state_t *s)
int ret;
ret = t81_t82_arith_decode_release(s);
free(s);
span_free(s);
return ret;
}
/*- End of function --------------------------------------------------------*/

View File

@ -35,6 +35,7 @@
#include <time.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/async.h"
#include "spandsp/timezone.h"
@ -399,7 +400,7 @@ SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], si
if (min_len > s->row_buf_len)
{
/* We need to expand the 3 row buffer */
if ((buf = (uint8_t *) realloc(s->row_buf, min_len)) == NULL)
if ((buf = (uint8_t *) span_realloc(s->row_buf, min_len)) == NULL)
return T4_DECODE_NOMEM;
s->row_buf = buf;
s->row_buf_len = min_len;
@ -409,7 +410,7 @@ SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], si
s->s.nopadding = s->options & T85_VLENGTH;
if (s->comment)
{
free(s->comment);
span_free(s->comment);
s->comment = NULL;
}
s->comment_len = 0;
@ -455,7 +456,7 @@ SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], si
s->interrupt = s->comment_handler(s->comment_user_data, s->comment, s->comment_len);
if (s->comment)
{
free(s->comment);
span_free(s->comment);
s->comment = NULL;
}
s->comment_len = 0;
@ -506,12 +507,12 @@ SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], si
s->comment_len = pack_32(&s->buffer[2]);
/* Only try to buffer and process the comment's contents if we have
a defined callback routine to do something with it. */
/* If this malloc fails we carry on working just fine, and don't try to
/* If this allocate fails we carry on working just fine, and don't try to
process the contents of the comment. That is fairly benign, as
the comments are not generally of critical importance, so let's
not worry. */
if (s->comment_handler && s->comment_len > 0 && s->comment_len <= s->max_comment_len)
s->comment = malloc(s->comment_len);
s->comment = span_alloc(s->comment_len);
s->comment_progress = 0;
continue;
case T82_ATMOVE:
@ -738,7 +739,7 @@ SPAN_DECLARE(int) t85_decode_new_plane(t85_decode_state_t *s)
s->end_of_data = 0;
if (s->comment)
{
free(s->comment);
span_free(s->comment);
s->comment = NULL;
}
s->comment_len = 0;
@ -786,7 +787,7 @@ SPAN_DECLARE(int) t85_decode_restart(t85_decode_state_t *s)
s->end_of_data = 0;
if (s->comment)
{
free(s->comment);
span_free(s->comment);
s->comment = NULL;
}
s->comment_len = 0;
@ -811,7 +812,7 @@ SPAN_DECLARE(t85_decode_state_t *) t85_decode_init(t85_decode_state_t *s,
{
if (s == NULL)
{
if ((s = (t85_decode_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (t85_decode_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -837,12 +838,12 @@ SPAN_DECLARE(int) t85_decode_release(t85_decode_state_t *s)
{
if (s->row_buf)
{
free(s->row_buf);
span_free(s->row_buf);
s->row_buf = NULL;
}
if (s->comment)
{
free(s->comment);
span_free(s->comment);
s->comment = NULL;
}
return 0;
@ -854,7 +855,7 @@ SPAN_DECLARE(int) t85_decode_free(t85_decode_state_t *s)
int ret;
ret = t85_decode_release(s);
free(s);
span_free(s);
return ret;
}
/*- End of function --------------------------------------------------------*/

View File

@ -35,6 +35,7 @@
#include <time.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/async.h"
#include "spandsp/timezone.h"
@ -78,7 +79,7 @@ static void put_stuff(t85_encode_state_t *s, const uint8_t buf[], int len)
/* The number of uncompressed bytes per row seems like a reasonable measure
of what to expect as a poor case for a compressed row. */
bytes_per_row = (s->xd + 7) >> 3;
if ((new_buf = realloc(s->bitstream, s->bitstream_len + len + bytes_per_row)) == NULL)
if ((new_buf = span_realloc(s->bitstream, s->bitstream_len + len + bytes_per_row)) == NULL)
return;
s->bitstream = new_buf;
s->bitstream_len += (len + bytes_per_row);
@ -518,7 +519,7 @@ SPAN_DECLARE(int) t85_encode_set_image_width(t85_encode_state_t *s, uint32_t ima
return -1;
s->xd = image_width;
bytes_per_row = (s->xd + 7) >> 3;
if ((t = (uint8_t *) realloc(s->row_buf, 3*bytes_per_row)) == NULL)
if ((t = (uint8_t *) span_realloc(s->row_buf, 3*bytes_per_row)) == NULL)
return -1;
s->row_buf = t;
memset(s->row_buf, 0, 3*bytes_per_row);
@ -663,7 +664,7 @@ SPAN_DECLARE(int) t85_encode_restart(t85_encode_state_t *s, uint32_t image_width
s->bitstream_optr = 0;
if (s->bitstream)
{
free(s->bitstream);
span_free(s->bitstream);
s->bitstream = NULL;
}
s->bitstream_len = 0;
@ -689,7 +690,7 @@ SPAN_DECLARE(t85_encode_state_t *) t85_encode_init(t85_encode_state_t *s,
{
if (s == NULL)
{
if ((s = (t85_encode_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (t85_encode_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -722,12 +723,12 @@ SPAN_DECLARE(int) t85_encode_release(t85_encode_state_t *s)
{
if (s->row_buf)
{
free(s->row_buf);
span_free(s->row_buf);
s->row_buf = NULL;
}
if (s->bitstream)
{
free(s->bitstream);
span_free(s->bitstream);
s->bitstream = NULL;
s->bitstream_len = 0;
}
@ -740,7 +741,7 @@ SPAN_DECLARE(int) t85_encode_free(t85_encode_state_t *s)
int ret;
ret = t85_encode_release(s);
free(s);
span_free(s);
return ret;
}
/*- End of function --------------------------------------------------------*/

View File

@ -45,6 +45,7 @@
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/time_scale.h"
#include "spandsp/saturated.h"
@ -132,7 +133,7 @@ SPAN_DECLARE(time_scale_state_t *) time_scale_init(time_scale_state_t *s, int sa
alloced = FALSE;
if (s == NULL)
{
if ((s = (time_scale_state_t *) malloc(sizeof (*s))) == NULL)
if ((s = (time_scale_state_t *) span_alloc(sizeof (*s))) == NULL)
return NULL;
/*endif*/
alloced = TRUE;
@ -145,7 +146,7 @@ SPAN_DECLARE(time_scale_state_t *) time_scale_init(time_scale_state_t *s, int sa
if (time_scale_rate(s, playout_rate))
{
if (alloced)
free(s);
span_free(s);
return NULL;
}
/*endif*/
@ -164,7 +165,7 @@ SPAN_DECLARE(int) time_scale_release(time_scale_state_t *s)
SPAN_DECLARE(int) time_scale_free(time_scale_state_t *s)
{
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -47,6 +47,7 @@
#include <assert.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/timezone.h"
#include "spandsp/private/timezone.h"
@ -796,7 +797,7 @@ SPAN_DECLARE(tz_t *) tz_init(tz_t *tz, const char *tzstring)
{
if (tz == NULL)
{
if ((tz = (tz_t *) malloc(sizeof(*tz))) == NULL)
if ((tz = (tz_t *) span_alloc(sizeof(*tz))) == NULL)
return NULL;
}
memset(tz, 0, sizeof(*tz));
@ -816,7 +817,7 @@ SPAN_DECLARE(int) tz_release(tz_t *tz)
SPAN_DECLARE(int) tz_free(tz_t *tz)
{
if (tz)
free(tz);
span_free(tz);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -44,6 +44,7 @@
#include <fcntl.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/complex.h"
#include "spandsp/complex_vector_float.h"
#include "spandsp/tone_detect.h"
@ -72,7 +73,7 @@ SPAN_DECLARE(goertzel_state_t *) goertzel_init(goertzel_state_t *s,
{
if (s == NULL)
{
if ((s = (goertzel_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (goertzel_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
#if defined(SPANDSP_USE_FIXED_POINT)
@ -98,7 +99,7 @@ SPAN_DECLARE(int) goertzel_release(goertzel_state_t *s)
SPAN_DECLARE(int) goertzel_free(goertzel_state_t *s)
{
if (s)
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -44,6 +44,7 @@
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/complex.h"
#include "spandsp/dds.h"
@ -69,7 +70,7 @@ SPAN_DECLARE(tone_gen_descriptor_t *) tone_gen_descriptor_init(tone_gen_descript
{
if (s == NULL)
{
if ((s = (tone_gen_descriptor_t *) malloc(sizeof(*s))) == NULL)
if ((s = (tone_gen_descriptor_t *) span_alloc(sizeof(*s))) == NULL)
{
return NULL;
}
@ -114,7 +115,7 @@ SPAN_DECLARE(tone_gen_descriptor_t *) tone_gen_descriptor_init(tone_gen_descript
SPAN_DECLARE(void) tone_gen_descriptor_free(tone_gen_descriptor_t *s)
{
free(s);
span_free(s);
}
/*- End of function --------------------------------------------------------*/
@ -220,7 +221,7 @@ SPAN_DECLARE(tone_gen_state_t *) tone_gen_init(tone_gen_state_t *s, tone_gen_des
if (s == NULL)
{
if ((s = (tone_gen_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (tone_gen_state_t *) span_alloc(sizeof(*s))) == NULL)
{
return NULL;
}
@ -252,7 +253,7 @@ SPAN_DECLARE(int) tone_gen_release(tone_gen_state_t *s)
SPAN_DECLARE(int) tone_gen_free(tone_gen_state_t *s)
{
if (s)
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -41,6 +41,7 @@
#include <assert.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/bit_operations.h"
#include "spandsp/async.h"
@ -1509,7 +1510,7 @@ SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *ss,
if (ss == NULL)
{
if ((ss = (v42_state_t *) malloc(sizeof(*ss))) == NULL)
if ((ss = (v42_state_t *) span_alloc(sizeof(*ss))) == NULL)
return NULL;
}
memset(ss, 0, sizeof(*ss));
@ -1564,7 +1565,7 @@ SPAN_DECLARE(int) v42_release(v42_state_t *s)
SPAN_DECLARE(int) v42_free(v42_state_t *s)
{
v42_release(s);
free(s);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -39,6 +39,7 @@
#include <assert.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/bit_operations.h"
#include "spandsp/async.h"
@ -729,7 +730,7 @@ SPAN_DECLARE(v42bis_state_t *) v42bis_init(v42bis_state_t *s,
return NULL;
if (s == NULL)
{
if ((s = (v42bis_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (v42bis_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -760,6 +761,7 @@ SPAN_DECLARE(int) v42bis_free(v42bis_state_t *s)
{
comp_exit(&s->compress);
comp_exit(&s->decompress);
span_free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -42,6 +42,7 @@
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/queue.h"
#include "spandsp/async.h"
@ -1078,7 +1079,7 @@ SPAN_DECLARE(v8_state_t *) v8_init(v8_state_t *s,
{
if (s == NULL)
{
if ((s = (v8_state_t *) malloc(sizeof(*s))) == NULL)
if ((s = (v8_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
@ -1103,7 +1104,7 @@ SPAN_DECLARE(int) v8_free(v8_state_t *s)
int ret;
ret = queue_free(s->tx_queue);
free(s);
span_free(s);
return ret;
}
/*- End of function --------------------------------------------------------*/