]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Moved a lot of spandsp to the use of custom allocation functions
authorSteve Underwood <steveu@haswell.coppice.org>
Mon, 5 Aug 2013 16:49:15 +0000 (00:49 +0800)
committerSteve Underwood <steveu@haswell.coppice.org>
Mon, 5 Aug 2013 16:49:15 +0000 (00:49 +0800)
46 files changed:
libs/spandsp/src/ademco_contactid.c
libs/spandsp/src/adsi.c
libs/spandsp/src/alloc.c
libs/spandsp/src/async.c
libs/spandsp/src/at_interpreter.c
libs/spandsp/src/awgn.c
libs/spandsp/src/bell_r2_mf.c
libs/spandsp/src/bert.c
libs/spandsp/src/bitstream.c
libs/spandsp/src/complex_filters.c
libs/spandsp/src/dtmf.c
libs/spandsp/src/echo.c
libs/spandsp/src/fax.c
libs/spandsp/src/fax_modems.c
libs/spandsp/src/g711.c
libs/spandsp/src/g722.c
libs/spandsp/src/g726.c
libs/spandsp/src/gsm0610_encode.c
libs/spandsp/src/logging.c
libs/spandsp/src/lpc10_decode.c
libs/spandsp/src/lpc10_encode.c
libs/spandsp/src/modem_connect_tones.c
libs/spandsp/src/modem_echo.c
libs/spandsp/src/noise.c
libs/spandsp/src/oki_adpcm.c
libs/spandsp/src/playout.c
libs/spandsp/src/plc.c
libs/spandsp/src/power_meter.c
libs/spandsp/src/queue.c
libs/spandsp/src/schedule.c
libs/spandsp/src/sig_tone.c
libs/spandsp/src/silence_gen.c
libs/spandsp/src/super_tone_rx.c
libs/spandsp/src/super_tone_tx.c
libs/spandsp/src/swept_tone.c
libs/spandsp/src/t30_api.c
libs/spandsp/src/t81_t82_arith_coding.c
libs/spandsp/src/t85_decode.c
libs/spandsp/src/t85_encode.c
libs/spandsp/src/time_scale.c
libs/spandsp/src/timezone.c
libs/spandsp/src/tone_detect.c
libs/spandsp/src/tone_generate.c
libs/spandsp/src/v42.c
libs/spandsp/src/v42bis.c
libs/spandsp/src/v8.c

index 6aaf99c3824cb4b0ab60caf0432c7b82124d520e..29d1130b9913ff801901bb51ed1736efefd3070a 100644 (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 --------------------------------------------------------*/
index df327bf3c5eb9fead4bb2cbc734b0566f343fd93..24e87d65ecb35dcd6373fca55932d3338cbd8b1a 100644 (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 --------------------------------------------------------*/
index e75c603c9f9f30f5344047cd46690e80761842cb..d02291248c06d03be4419751bb6a9c1335e930b2 100644 (file)
 #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;
index fb381bb7bc33daac8ee42a00729552abd05af41e..15c73adcc000d95721a13b85b033647958d79743 100644 (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 --------------------------------------------------------*/
index 2ecdbb866d5e970a45bf49354236c7d9532ed318..d36532afbd5d8e2d7a14a65f494932064791c267 100644 (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 --------------------------------------------------------*/
index 582959cc933a9a3743460baa8e47804049956ae8..fa33b1b4c5923794914efad13674947bb4a13764 100644 (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 --------------------------------------------------------*/
index dba407cddd141ff366933c17109dc88d76f07e94..493f766f9c971a02ea089ad8d846716e7fa8b0b0 100644 (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 --------------------------------------------------------*/
index a8ad5ad6b73d9bdff2d4a7323e5d3403a8be53b7..a4081f66d1981d28301875a4bacef71b2d02ab90 100644 (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 --------------------------------------------------------*/
index 9a8c0bc9ddbf7379cf0ae65aabe03e3ac35f1adc..f3da9c4d0b8d72c2e236f2b16e81ae4a0876a6be 100644 (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 --------------------------------------------------------*/
index d54e55818a43ac049f238cf7fc168cc70198cef8..22cf4ac9b8f49f14aef4c7d86900a1e76e8bf7b6 100644 (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;
         }
     }
index 991f3d6a852b6bc634c9e7eafcc2d357318a43ff..e58552de58f03d0f4f9aea477ae5c2fcf7feb3d1 100644 (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 --------------------------------------------------------*/
index 84926fa3c4c75971f6c08ff16791409a6e1fcbae..18c4ba4c1ffd021359d2af2d01ce9d13ff1b7bc4 100644 (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 --------------------------------------------------------*/
index ef7e33433a3f6500e0173c7254f337996d43368a..b07aa002c5d7aae4f4ce4f62d5d720389d34c0a4 100644 (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 --------------------------------------------------------*/
index 3cf658e4dffde40f4ca64b353b80aa87fb3db86e..69698bcaeb325195e84c2e50c9fbbeb25ad89e31 100644 (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;
 }
index 173bd2ae5370eab50a4ce3e54b5074423cbc5910..edccd27bb10896cd4aeea4e584e5783886fff214 100644 (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 --------------------------------------------------------*/
index 22715cfa4acb076f687d9cc9642a73b7eaa6a133..bbf3bbfc0fedc72ad06d8fdff318d0bcb6745aa4 100644 (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 --------------------------------------------------------*/
index 6be385fc5fc26bd6b5a857d866a32d8c58d30cd8..ba1c5b913e9936a7aa3c43b2ff698d0d18d51055 100644 (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 --------------------------------------------------------*/
index 2c359688fede95f2d9a86353bb07931a52435d7d..eeac7d288130c0bf64f47248a2a765ac727fc8b0 100644 (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;
 }
index 3f9aa58f17e7b7636f30ba5e514d5472482d8dee..68975b0e042e9a22d3a24f7d8d12d003ac83ad05 100644 (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 --------------------------------------------------------*/
index 19860e149d9bc9b68ee4e273a5df379cd303be06..eb6d9968cb57f65ea7754bf80810d169fbf735ed 100644 (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 --------------------------------------------------------*/
index 739734f8662b177e6e34e64fae23d4fd0e2cc3c0..976fc602d0ae8759528fac729f10bcf1353648ce 100644 (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 --------------------------------------------------------*/
index 76b42a23fc7b9300363f5137f8f7c20f38fc3422..6a08781f66e8da3a895f6a82f250a833f320e124 100644 (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 --------------------------------------------------------*/
index 14257c7eb7f7ccad4b43e1b0d4165c2e74b192f7..59bf57b544f35f42aa30fbdbaa14865959339a4e 100644 (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;
index 5d7fe23aad0fa4f86757f184dac8549b556acd1d..3ad164cf7f2347ceb458943d9418a981eada60be 100644 (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 --------------------------------------------------------*/
index f6d54b804c49368b1e519e27520c7f7448f720b8..0e5e8f6659120dd6cfc044f59a88d93243e36b26 100644 (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 --------------------------------------------------------*/
index e98e48d70c8e364100346ca5f8d362c99cb2dae9..60a8d9767426be3ba0e7e5e6d0bc7d99e89ca3dc 100644 (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;
 }
index dcb07120e1227cb599517d96febd32dda64a1a1c..840682a8fc7825391f02420c23c4b03995e3f254 100644 (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 --------------------------------------------------------*/
index f4fb2afa8f1b78658530e62f82574c4056daa4db..984393021568a18bb877b883ce7583010a4cdcda 100644 (file)
 #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 --------------------------------------------------------*/
index 264cee0c87ee5327ddf6ff6f76ed02b50921a41d..3f55e833eace9ce76b91abd0ef9657ea87fbe9d6 100644 (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 --------------------------------------------------------*/
index 60ba12bc1f020981c00714d64e0181d512ad7c34..f65b5d7764ef9e4ea62ef28a3bf513a5568af20e 100644 (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 --------------------------------------------------------*/
index 5e4e18017800aa8d2d312932d3a24a8595ef2069..698c07180ecd78e1f4e59b308b014cd0c75c4edc 100644 (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 --------------------------------------------------------*/
index ad7d7caed0c68b396f688a94bfa0d780002040d5..d89f9c8e42c4de52b8b867db77a5dc093f082fa5 100644 (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 --------------------------------------------------------*/
index e46faa814885f3663eb1cee1035570ce84a89119..eabebe6a30b96a36b60d7a12c6f71574b90145c3 100644 (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 --------------------------------------------------------*/
index 3809bb4bf8e9a0c02f670f9ab5f91ca47e336b85..5b8ab4303d999115123db79f91323937d4e6479a 100644 (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 --------------------------------------------------------*/
index f5ccc9bed8c1c898c4cc50c63ace3fbfd7bc9aa8..20eb7d5de958385e4c1b211cb3267fe71e105435 100644 (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 --------------------------------------------------------*/
index 7ab68677c3b8aefe7005c653fec09d83d6a3a4b2..d00ede33d284d8476c727ae5cb562b28f58f7be5 100644 (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;
index 86e7e0271f75017216e3244078becb8d6aaf2eb4..5d51bbc25d4edb2446246a7e9a132ccf4fc58dbe 100644 (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 --------------------------------------------------------*/
index 93efc06e81b338e5b97e8cfd6ef74f224b029fec..f48502c9d9a1e3c4b880ba6436761f7358ca5dc0 100644 (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 --------------------------------------------------------*/
index ed8e47364ffff90885d0e2cdf7c618e67354b287..9b417a39fd9d4dd13a3a5bb4d7985be2cc10590a 100644 (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 --------------------------------------------------------*/
index 5b2a64a66b218860f0f1e33db30d51e78ede2e94..a817834d22aafaa1208f07de35b8a333c2d0d11c 100644 (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 --------------------------------------------------------*/
index 79966f1d4cc41436a695457826797b6171990a2f..158b0100dac7fca1430bd7be693dd10f3b95e8f9 100644 (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 --------------------------------------------------------*/
index 4dfea5d5bfde71600e2f6b68d085c0d6d9701fc2..2865ba40d84c3dea78fd63e9dbe7dd4d2f22a59c 100644 (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 --------------------------------------------------------*/
index 21285f6a968fbc19ae895f61208fdeaa88119af6..be3f6854a432fb0d3a661b94955bef5ad8f2cb26 100644 (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 --------------------------------------------------------*/
index 29255eea07d33fcbc4c26766086aa3e8a2f063c3..33a4573052e5114e7b8dbb824ca9df635e0b868b 100644 (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 --------------------------------------------------------*/
index fec129a6f2591826690c7c3e035e8ae18c111ff1..cc34c54be94f25b8da5792f13e88e05c0ca30dd8 100644 (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 --------------------------------------------------------*/
index 3cf63ceacba9793908229202bec95c2c139eadda..fb8436651c0282f53b58e48db96e23ed98084fd5 100644 (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 --------------------------------------------------------*/