]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
More movements of spandsp to the sue of custom allocation routines
authorSteve Underwood <steveu@haswell.coppice.org>
Mon, 5 Aug 2013 17:10:48 +0000 (01:10 +0800)
committerSteve Underwood <steveu@haswell.coppice.org>
Mon, 5 Aug 2013 17:10:48 +0000 (01:10 +0800)
21 files changed:
libs/spandsp/src/fsk.c
libs/spandsp/src/hdlc.c
libs/spandsp/src/ima_adpcm.c
libs/spandsp/src/image_translate.c
libs/spandsp/src/modem_echo.c
libs/spandsp/src/t31.c
libs/spandsp/src/t38_core.c
libs/spandsp/src/t38_gateway.c
libs/spandsp/src/t38_non_ecm_buffer.c
libs/spandsp/src/t38_terminal.c
libs/spandsp/src/t42.c
libs/spandsp/src/t43.c
libs/spandsp/src/t4_t6_decode.c
libs/spandsp/src/t4_t6_encode.c
libs/spandsp/src/v17tx.c
libs/spandsp/src/v18.c
libs/spandsp/src/v22bis_tx.c
libs/spandsp/src/v27ter_rx.c
libs/spandsp/src/v27ter_tx.c
libs/spandsp/src/v29rx.c
libs/spandsp/src/v29tx.c

index 2c1d326d843145a83b94a43df7b54fcb4cf3b942..7e6619a58f6c6f611bd7a0d59696b4b657ebc8cf 100644 (file)
@@ -42,6 +42,7 @@
 #include <assert.h>
 
 #include "spandsp/telephony.h"
+#include "spandsp/alloc.h"
 #include "spandsp/complex.h"
 #include "spandsp/dds.h"
 #include "spandsp/power_meter.h"
@@ -166,7 +167,7 @@ SPAN_DECLARE(fsk_tx_state_t *) fsk_tx_init(fsk_tx_state_t *s,
 {
     if (s == NULL)
     {
-        if ((s = (fsk_tx_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (fsk_tx_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -186,7 +187,7 @@ SPAN_DECLARE(int) fsk_tx_release(fsk_tx_state_t *s)
 
 SPAN_DECLARE(int) fsk_tx_free(fsk_tx_state_t *s)
 {
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
@@ -328,7 +329,7 @@ SPAN_DECLARE(fsk_rx_state_t *) fsk_rx_init(fsk_rx_state_t *s,
 {
     if (s == NULL)
     {
-        if ((s = (fsk_rx_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (fsk_rx_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -348,7 +349,7 @@ SPAN_DECLARE(int) fsk_rx_release(fsk_rx_state_t *s)
 
 SPAN_DECLARE(int) fsk_rx_free(fsk_rx_state_t *s)
 {
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index 7733aa82809e70f214df4ba68473fa3fdffb47c1..3efaf3810ef13691946690bae38978dde463898a 100644 (file)
@@ -35,6 +35,7 @@
 #include <stdio.h>
 
 #include "spandsp/telephony.h"
+#include "spandsp/alloc.h"
 #include "spandsp/async.h"
 #include "spandsp/crc.h"
 #include "spandsp/bit_operations.h"
@@ -314,7 +315,7 @@ SPAN_DECLARE(hdlc_rx_state_t *) hdlc_rx_init(hdlc_rx_state_t *s,
 {
     if (s == NULL)
     {
-        if ((s = (hdlc_rx_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (hdlc_rx_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -350,7 +351,7 @@ SPAN_DECLARE(int) hdlc_rx_release(hdlc_rx_state_t *s)
 
 SPAN_DECLARE(int) hdlc_rx_free(hdlc_rx_state_t *s)
 {
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
@@ -592,7 +593,7 @@ SPAN_DECLARE(hdlc_tx_state_t *) hdlc_tx_init(hdlc_tx_state_t *s,
 {
     if (s == NULL)
     {
-        if ((s = (hdlc_tx_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (hdlc_tx_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -624,7 +625,7 @@ SPAN_DECLARE(int) hdlc_tx_release(hdlc_tx_state_t *s)
 
 SPAN_DECLARE(int) hdlc_tx_free(hdlc_tx_state_t *s)
 {
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index 6c4cc1637038cd1f765b296942ad11aa9c175499..fbd59df62183594ced9d7bead1ccbdfa843cf061 100644 (file)
@@ -42,6 +42,7 @@
 #include "floating_fudge.h"
 
 #include "spandsp/telephony.h"
+#include "spandsp/alloc.h"
 #include "spandsp/fast_convert.h"
 #include "spandsp/saturated.h"
 #include "spandsp/ima_adpcm.h"
@@ -282,7 +283,7 @@ SPAN_DECLARE(ima_adpcm_state_t *) ima_adpcm_init(ima_adpcm_state_t *s,
 {
     if (s == NULL)
     {
-        if ((s = (ima_adpcm_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (ima_adpcm_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     /*endif*/
@@ -301,7 +302,7 @@ SPAN_DECLARE(int) ima_adpcm_release(ima_adpcm_state_t *s)
 
 SPAN_DECLARE(int) ima_adpcm_free(ima_adpcm_state_t *s)
 {
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index b504ca907459d337813b4f52040ac92b9cedc51f..ef30f6f4d4467f0cef0fced8a735c7c61fa35342 100644 (file)
@@ -52,6 +52,7 @@
 #include <assert.h>
 
 #include "spandsp/telephony.h"
+#include "spandsp/alloc.h"
 #include "spandsp/fast_convert.h"
 #include "spandsp/logging.h"
 #include "spandsp/saturated.h"
@@ -712,7 +713,7 @@ SPAN_DECLARE(int) image_translate_restart(image_translate_state_t *s, int input_
         {
             if (s->raw_pixel_row[i] == NULL)
             {
-                if ((s->raw_pixel_row[i] = (uint8_t *) malloc(raw_row_size)) == NULL)
+                if ((s->raw_pixel_row[i] = (uint8_t *) span_alloc(raw_row_size)) == NULL)
                     return -1;
             }
             memset(s->raw_pixel_row[i], 0, raw_row_size);
@@ -729,7 +730,7 @@ SPAN_DECLARE(int) image_translate_restart(image_translate_state_t *s, int input_
         {
             if (s->pixel_row[i] == NULL)
             {
-                if ((s->pixel_row[i] = (uint8_t *) malloc(raw_row_size)) == NULL)
+                if ((s->pixel_row[i] = (uint8_t *) span_alloc(raw_row_size)) == NULL)
                     return -1;
             }
             memset(s->pixel_row[i], 0, raw_row_size);
@@ -757,7 +758,7 @@ SPAN_DECLARE(image_translate_state_t *) image_translate_init(image_translate_sta
 {
     if (s == NULL)
     {
-        if ((s = (image_translate_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (image_translate_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -794,12 +795,12 @@ SPAN_DECLARE(int) image_translate_release(image_translate_state_t *s)
     {
         if (s->raw_pixel_row[i])
         {
-            free(s->raw_pixel_row[i]);
+            span_free(s->raw_pixel_row[i]);
             s->raw_pixel_row[i] = NULL;
         }
         if (s->pixel_row[i])
         {
-            free(s->pixel_row[i]);
+            span_free(s->pixel_row[i]);
             s->pixel_row[i] = NULL;
         }
     }
@@ -812,7 +813,7 @@ SPAN_DECLARE(int) image_translate_free(image_translate_state_t *s)
     int res;
 
     res = image_translate_release(s);
-    free(s);
+    span_free(s);
     return res;
 }
 /*- End of function --------------------------------------------------------*/
index 59bf57b544f35f42aa30fbdbaa14865959339a4e..622c201279276353cd9c2bf44ae61d5d8f4b7c3a 100644 (file)
@@ -57,9 +57,9 @@
 SPAN_DECLARE(void) modem_echo_can_free(modem_echo_can_state_t *ec)
 {
     fir16_free(&ec->fir_state);
-    free(ec->fir_taps32);
-    free(ec->fir_taps16);
-    free(ec);
+    span_free(ec->fir_taps32);
+    span_free(ec->fir_taps16);
+    span_free(ec);
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -74,7 +74,7 @@ SPAN_DECLARE(modem_echo_can_state_t *) modem_echo_can_init(int len)
     ec->curr_pos = ec->taps - 1;
     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));
index 6a9f08d382341fed2a0aba9541dcaa36bd1c89c1..9993a7a521b5025e66b5211542a404bb216f9871 100644 (file)
@@ -51,6 +51,7 @@
 #include <tiffio.h>
 
 #include "spandsp/telephony.h"
+#include "spandsp/alloc.h"
 #include "spandsp/logging.h"
 #include "spandsp/bit_operations.h"
 #include "spandsp/bitstream.h"
@@ -3016,7 +3017,7 @@ SPAN_DECLARE(t31_state_t *) t31_init(t31_state_t *s,
     alloced = FALSE;
     if (s == NULL)
     {
-        if ((s = (t31_state_t *) malloc(sizeof (*s))) == NULL)
+        if ((s = (t31_state_t *) span_alloc(sizeof (*s))) == NULL)
             return NULL;
         /*endif*/
         alloced = TRUE;
@@ -3071,7 +3072,7 @@ SPAN_DECLARE(t31_state_t *) t31_init(t31_state_t *s,
     if ((s->rx_queue = queue_init(NULL, 4096, QUEUE_WRITE_ATOMIC | QUEUE_READ_ATOMIC)) == NULL)
     {
         if (alloced)
-            free(s);
+            span_free(s);
         /*endif*/
         return NULL;
     }
@@ -3100,7 +3101,7 @@ SPAN_DECLARE(int) t31_release(t31_state_t *s)
 SPAN_DECLARE(int) t31_free(t31_state_t *s)
 {
     t31_release(s);
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index ae6526f7e83e9ed0d02e1933411e170d0d8a184f..922e8a372a29e9688957a5b91fa27e46ab7a02b1 100644 (file)
@@ -47,6 +47,7 @@
 #include <tiffio.h>
 
 #include "spandsp/telephony.h"
+#include "spandsp/alloc.h"
 #include "spandsp/logging.h"
 #include "spandsp/bit_operations.h"
 #include "spandsp/t38_core.h"
@@ -1109,7 +1110,7 @@ SPAN_DECLARE(t38_core_state_t *) t38_core_init(t38_core_state_t *s,
 {
     if (s == NULL)
     {
-        if ((s = (t38_core_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (t38_core_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -1157,7 +1158,7 @@ SPAN_DECLARE(int) t38_core_release(t38_core_state_t *s)
 SPAN_DECLARE(int) t38_core_free(t38_core_state_t *s)
 {
     if (s)
-        free(s);
+        span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index 7656332e80a909436b694a11567d41ffe5b0d0f9..7078a37908a5e113c9cdc5618b6dc4d193e3a7aa 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"
@@ -2267,7 +2268,7 @@ SPAN_DECLARE(t38_gateway_state_t *) t38_gateway_init(t38_gateway_state_t *s,
     /*endif*/
     if (s == NULL)
     {
-        if ((s = (t38_gateway_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (t38_gateway_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
         /*endif*/
     }
@@ -2332,7 +2333,7 @@ SPAN_DECLARE(int) t38_gateway_release(t38_gateway_state_t *s)
 
 SPAN_DECLARE(int) t38_gateway_free(t38_gateway_state_t *s)
 {
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index cc339a058106998ecc341cfd62098ee07945d1ea..bd63c419f25368da0981d999d65fb6e9f22560a3 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/dc_restore.h"
@@ -351,7 +352,7 @@ SPAN_DECLARE(t38_non_ecm_buffer_state_t *) t38_non_ecm_buffer_init(t38_non_ecm_b
 {
     if (s == NULL)
     {
-        if ((s = (t38_non_ecm_buffer_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (t38_non_ecm_buffer_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -371,7 +372,7 @@ SPAN_DECLARE(int) t38_non_ecm_buffer_release(t38_non_ecm_buffer_state_t *s)
 SPAN_DECLARE(int) t38_non_ecm_buffer_free(t38_non_ecm_buffer_state_t *s)
 {
     if (s)
-        free(s);
+        span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index 66938d8d2454fed58dc436ce95dce53a0f69411a..02a9369f35ede462671b0c32f6099ec7db733d32 100644 (file)
@@ -46,6 +46,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"
@@ -1525,7 +1526,7 @@ SPAN_DECLARE(t38_terminal_state_t *) t38_terminal_init(t38_terminal_state_t *s,
 
     if (s == NULL)
     {
-        if ((s = (t38_terminal_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (t38_terminal_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
         /*endif*/
     }
@@ -1564,7 +1565,7 @@ SPAN_DECLARE(int) t38_terminal_release(t38_terminal_state_t *s)
 SPAN_DECLARE(int) t38_terminal_free(t38_terminal_state_t *s)
 {
     t38_terminal_release(s);
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index 8d0023f7d7fd69c35ee8595dfc6ec66257747d1b..5a00a4121e4d13f30d0be2580f13dab53db7ac66 100644 (file)
@@ -50,6 +50,7 @@
 #include <assert.h>
 
 #include "spandsp/telephony.h"
+#include "spandsp/alloc.h"
 #include "spandsp/fast_convert.h"
 #include "spandsp/logging.h"
 #include "spandsp/saturated.h"
@@ -742,7 +743,7 @@ static int t42_srgb_to_itulab_jpeg(t42_encode_state_t *s)
             span_log(&s->logging, SPAN_LOG_FLOW, "Unspecified libjpeg error.\n");
         if (s->scan_line_out)
         {
-            free(s->scan_line_out);
+            span_free(s->scan_line_out);
             s->scan_line_out = NULL;
         }
         if (s->out)
@@ -802,12 +803,12 @@ static int t42_srgb_to_itulab_jpeg(t42_encode_state_t *s)
 
     set_itu_fax(s);
 
-    if ((s->scan_line_in = (JSAMPROW) malloc(s->samples_per_pixel*s->image_width)) == NULL)
+    if ((s->scan_line_in = (JSAMPROW) span_alloc(s->samples_per_pixel*s->image_width)) == NULL)
         return -1;
 
     if (s->image_type == T4_IMAGE_TYPE_COLOUR_8BIT)
     {
-        if ((s->scan_line_out = (JSAMPROW) malloc(s->samples_per_pixel*s->image_width)) == NULL)
+        if ((s->scan_line_out = (JSAMPROW) span_alloc(s->samples_per_pixel*s->image_width)) == NULL)
             return -1;
 
         for (i = 0;  i < s->compressor.image_height;  i++)
@@ -828,7 +829,7 @@ static int t42_srgb_to_itulab_jpeg(t42_encode_state_t *s)
 
     if (s->scan_line_out)
     {
-        free(s->scan_line_out);
+        span_free(s->scan_line_out);
         s->scan_line_out = NULL;
     }
     jpeg_finish_compress(&s->compressor);
@@ -841,13 +842,13 @@ static int t42_srgb_to_itulab_jpeg(t42_encode_state_t *s)
 #else
     s->buf_size =
     s->compressed_image_size = ftell(s->out);
-    if ((s->compressed_buf = malloc(s->compressed_image_size)) == NULL)
+    if ((s->compressed_buf = span_alloc(s->compressed_image_size)) == NULL)
         return -1;
     if (fseek(s->out, 0, SEEK_SET) != 0)
     {
         fclose(s->out);
         s->out = NULL;
-        free(s->compressed_buf);
+        span_free(s->compressed_buf);
         s->compressed_buf = NULL;
         return -1;
     }
@@ -855,7 +856,7 @@ static int t42_srgb_to_itulab_jpeg(t42_encode_state_t *s)
     {
         fclose(s->out);
         s->out = NULL;
-        free(s->compressed_buf);
+        span_free(s->compressed_buf);
         s->compressed_buf = NULL;
         return -1;
     }
@@ -986,7 +987,7 @@ SPAN_DECLARE(t42_encode_state_t *) t42_encode_init(t42_encode_state_t *s,
 {
     if (s == NULL)
     {
-        if ((s = (t42_encode_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (t42_encode_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -1016,7 +1017,7 @@ SPAN_DECLARE(int) t42_encode_free(t42_encode_state_t *s)
     int ret;
 
     ret = t42_encode_release(s);
-    free(s);
+    span_free(s);
     return ret;
 }
 /*- End of function --------------------------------------------------------*/
@@ -1087,7 +1088,7 @@ static int t42_itulab_jpeg_to_srgb(t42_decode_state_t *s)
             span_log(&s->logging, SPAN_LOG_FLOW, "Unspecified libjpeg error.\n");
         if (s->scan_line_out)
         {
-            free(s->scan_line_out);
+            span_free(s->scan_line_out);
             s->scan_line_out = NULL;
         }
         if (s->in)
@@ -1155,12 +1156,12 @@ static int t42_itulab_jpeg_to_srgb(t42_decode_state_t *s)
 
     jpeg_start_decompress(&s->decompressor);
 
-    if ((s->scan_line_in = malloc(s->samples_per_pixel*s->image_width)) == NULL)
+    if ((s->scan_line_in = span_alloc(s->samples_per_pixel*s->image_width)) == NULL)
         return -1;
 
     if (s->samples_per_pixel == 3)
     {
-        if ((s->scan_line_out = malloc(s->samples_per_pixel*s->image_width)) == NULL)
+        if ((s->scan_line_out = span_alloc(s->samples_per_pixel*s->image_width)) == NULL)
             return -1;
 
         while (s->decompressor.output_scanline < s->image_length)
@@ -1181,12 +1182,12 @@ static int t42_itulab_jpeg_to_srgb(t42_decode_state_t *s)
 
     if (s->scan_line_in)
     {
-        free(s->scan_line_in);
+        span_free(s->scan_line_in);
         s->scan_line_in = NULL;
     }
     if (s->scan_line_out)
     {
-        free(s->scan_line_out);
+        span_free(s->scan_line_out);
         s->scan_line_out = NULL;
     }
     jpeg_finish_decompress(&s->decompressor);
@@ -1243,7 +1244,7 @@ SPAN_DECLARE(int) t42_decode_put(t42_decode_state_t *s, const uint8_t data[], si
 
     if (s->compressed_image_size + len > s->buf_size)
     {
-        if ((buf = (uint8_t *) realloc(s->compressed_buf, s->compressed_image_size + len + 10000)) == NULL)
+        if ((buf = (uint8_t *) span_realloc(s->compressed_buf, s->compressed_image_size + len + 10000)) == NULL)
             return -1;
         s->buf_size = s->compressed_image_size + len + 10000;
         s->compressed_buf = buf;
@@ -1340,7 +1341,7 @@ SPAN_DECLARE(t42_decode_state_t *) t42_decode_init(t42_decode_state_t *s,
 {
     if (s == NULL)
     {
-        if ((s = (t42_decode_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (t42_decode_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -1363,12 +1364,12 @@ SPAN_DECLARE(int) t42_decode_release(t42_decode_state_t *s)
 {
     if (s->scan_line_in)
     {
-        free(s->scan_line_in);
+        span_free(s->scan_line_in);
         s->scan_line_in = NULL;
     }
     if (s->scan_line_out)
     {
-        free(s->scan_line_out);
+        span_free(s->scan_line_out);
         s->scan_line_out = NULL;
     }
     jpeg_destroy_decompress(&s->decompressor);
@@ -1379,7 +1380,7 @@ SPAN_DECLARE(int) t42_decode_release(t42_decode_state_t *s)
     }
     if (s->comment)
     {
-        free(s->comment);
+        span_free(s->comment);
         s->comment = NULL;
     }
     return 0;
@@ -1391,7 +1392,7 @@ SPAN_DECLARE(int) t42_decode_free(t42_decode_state_t *s)
     int ret;
 
     ret = t42_decode_release(s);
-    free(s);
+    span_free(s);
     return ret;
 }
 /*- End of function --------------------------------------------------------*/
index b0e1abffb9c847bca7a2984fa8ac8b8823bac3e6..9e2ee76be2012267b7d20910f423c8614ad90734 100644 (file)
@@ -44,6 +44,7 @@
 #include <setjmp.h>
 
 #include "spandsp/telephony.h"
+#include "spandsp/alloc.h"
 #include "spandsp/logging.h"
 #include "spandsp/async.h"
 #include "spandsp/timezone.h"
@@ -133,7 +134,9 @@ static int t43_create_header(t43_encode_state_t *s, uint8_t data[], size_t len)
 {
     int pos;
     int val[6];
+#if 0
     int bytes_per_entry;
+#endif
 
     pos = 0;
     unpack_16(data, 0xFFA8);
@@ -345,7 +348,7 @@ SPAN_DECLARE(t43_encode_state_t *) t43_encode_init(t43_encode_state_t *s,
 {
     if (s == NULL)
     {
-        if ((s = (t43_encode_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (t43_encode_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -380,7 +383,7 @@ SPAN_DECLARE(int) t43_encode_free(t43_encode_state_t *s)
 
     t85_encode_free(&s->t85);
     ret = t43_encode_release(s);
-    free(s);
+    span_free(s);
     return ret;
 }
 /*- End of function --------------------------------------------------------*/
@@ -700,7 +703,7 @@ static int t85_row_write_handler(void *user_data, const uint8_t buf[], size_t le
     if (s->buf == NULL)
     {
         image_size = s->samples_per_pixel*s->t85.xd*s->t85.yd;
-        if ((s->buf = malloc(image_size)) == NULL)
+        if ((s->buf = span_alloc(image_size)) == NULL)
             return -1;
         memset(s->buf, 0, image_size);
     }
@@ -761,6 +764,7 @@ SPAN_DECLARE(int) t43_decode_put(t43_decode_state_t *s, const uint8_t data[], si
     }
 
     /* Now deal the bit-planes, one after another. */
+    total_len = 0;
     while (s->current_bit_plane < s->t85.bit_planes)
     {
         j = s->current_bit_plane;
@@ -882,7 +886,7 @@ SPAN_DECLARE(t43_decode_state_t *) t43_decode_init(t43_decode_state_t *s,
 {
     if (s == NULL)
     {
-        if ((s = (t43_decode_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (t43_decode_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -922,7 +926,7 @@ SPAN_DECLARE(int) t43_decode_free(t43_decode_state_t *s)
 
     ret = t43_decode_release(s);
     t85_decode_free(&s->t85);
-    free(s);
+    span_free(s);
     return ret;
 }
 /*- End of function --------------------------------------------------------*/
index c347dfd19a862b6b5862263ab3cc8fe1bca1034c..219a0bafb83cc760dc1bb95c4956782870a15890 100644 (file)
@@ -79,6 +79,7 @@
 #include <tiffio.h>
 
 #include "spandsp/telephony.h"
+#include "spandsp/alloc.h"
 #include "spandsp/logging.h"
 #include "spandsp/bit_operations.h"
 #include "spandsp/async.h"
@@ -138,17 +139,17 @@ static int free_buffers(t4_t6_decode_state_t *s)
 {
     if (s->cur_runs)
     {
-        free(s->cur_runs);
+        span_free(s->cur_runs);
         s->cur_runs = NULL;
     }
     if (s->ref_runs)
     {
-        free(s->ref_runs);
+        span_free(s->ref_runs);
         s->ref_runs = NULL;
     }
     if (s->row_buf)
     {
-        free(s->row_buf);
+        span_free(s->row_buf);
         s->row_buf = NULL;
     }
     s->bytes_per_row = 0;
@@ -824,10 +825,10 @@ SPAN_DECLARE(int) t4_t6_decode_restart(t4_t6_decode_state_t *s, int image_width)
     if (s->bytes_per_row == 0  ||  image_width != s->image_width)
     {
         /* Allocate the space required for decoding the new row length. */
-        if ((bufptr = (uint32_t *) realloc(s->cur_runs, run_space)) == NULL)
+        if ((bufptr = (uint32_t *) span_realloc(s->cur_runs, run_space)) == NULL)
             return -1;
         s->cur_runs = bufptr;
-        if ((bufptr = (uint32_t *) realloc(s->ref_runs, run_space)) == NULL)
+        if ((bufptr = (uint32_t *) span_realloc(s->ref_runs, run_space)) == NULL)
             return -1;
         s->ref_runs = bufptr;
         s->image_width = image_width;
@@ -835,7 +836,7 @@ SPAN_DECLARE(int) t4_t6_decode_restart(t4_t6_decode_state_t *s, int image_width)
     bytes_per_row = (image_width + 7)/8;
     if (bytes_per_row != s->bytes_per_row)
     {
-        if ((bufptr8 = (uint8_t *) realloc(s->row_buf, bytes_per_row)) == NULL)
+        if ((bufptr8 = (uint8_t *) span_realloc(s->row_buf, bytes_per_row)) == NULL)
             return -1;
         s->row_buf = bufptr8;
         s->bytes_per_row = bytes_per_row;
@@ -892,7 +893,7 @@ SPAN_DECLARE(t4_t6_decode_state_t *) t4_t6_decode_init(t4_t6_decode_state_t *s,
 {
     if (s == NULL)
     {
-        if ((s = (t4_t6_decode_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (t4_t6_decode_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -919,7 +920,7 @@ SPAN_DECLARE(int) t4_t6_decode_free(t4_t6_decode_state_t *s)
     int ret;
 
     ret = t4_t6_decode_release(s);
-    free(s);
+    span_free(s);
     return ret;
 }
 /*- End of function --------------------------------------------------------*/
index 4ed063e063cbf60e6c94477884218498cc92b68b..fde78f48273065da1299964d5c566b68b10831cf 100644 (file)
@@ -76,6 +76,7 @@
 #include <tiffio.h>
 
 #include "spandsp/telephony.h"
+#include "spandsp/alloc.h"
 #include "spandsp/logging.h"
 #include "spandsp/bit_operations.h"
 #include "spandsp/async.h"
@@ -373,17 +374,17 @@ static int free_buffers(t4_t6_encode_state_t *s)
 {
     if (s->cur_runs)
     {
-        free(s->cur_runs);
+        span_free(s->cur_runs);
         s->cur_runs = NULL;
     }
     if (s->ref_runs)
     {
-        free(s->ref_runs);
+        span_free(s->ref_runs);
         s->ref_runs = NULL;
     }
     if (s->bitstream)
     {
-        free(s->bitstream);
+        span_free(s->bitstream);
         s->bitstream = NULL;
     }
     s->bytes_per_row = 0;
@@ -1026,13 +1027,13 @@ SPAN_DECLARE(int) t4_t6_encode_set_image_width(t4_t6_encode_state_t *s, int imag
         s->bytes_per_row = (s->image_width + 7)/8;
         run_space = (s->image_width + 4)*sizeof(uint32_t);
 
-        if ((bufptr = (uint32_t *) realloc(s->cur_runs, run_space)) == NULL)
+        if ((bufptr = (uint32_t *) span_realloc(s->cur_runs, run_space)) == NULL)
             return -1;
         s->cur_runs = bufptr;
-        if ((bufptr = (uint32_t *) realloc(s->ref_runs, run_space)) == NULL)
+        if ((bufptr = (uint32_t *) span_realloc(s->ref_runs, run_space)) == NULL)
             return -1;
         s->ref_runs = bufptr;
-        if ((bufptr8 = (uint8_t *) realloc(s->bitstream, (s->image_width + 1)*sizeof(uint16_t))) == NULL)
+        if ((bufptr8 = (uint8_t *) span_realloc(s->bitstream, (s->image_width + 1)*sizeof(uint16_t))) == NULL)
             return -1;
         s->bitstream = bufptr8;
     }
@@ -1151,7 +1152,7 @@ SPAN_DECLARE(t4_t6_encode_state_t *) t4_t6_encode_init(t4_t6_encode_state_t *s,
 {
     if (s == NULL)
     {
-        if ((s = (t4_t6_encode_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (t4_t6_encode_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -1181,7 +1182,7 @@ SPAN_DECLARE(int) t4_t6_encode_free(t4_t6_encode_state_t *s)
     int ret;
 
     ret = t4_t6_encode_release(s);
-    free(s);
+    span_free(s);
     return ret;
 }
 /*- End of function --------------------------------------------------------*/
index fe361d7744661a2f96fd43c56425758e22a834f7..b4f9f3e80a06654006f6d8ff3d14550b11d7cfa7 100644 (file)
@@ -42,6 +42,7 @@
 #include "floating_fudge.h"
 
 #include "spandsp/telephony.h"
+#include "spandsp/alloc.h"
 #include "spandsp/fast_convert.h"
 #include "spandsp/logging.h"
 #include "spandsp/complex.h"
@@ -449,7 +450,7 @@ SPAN_DECLARE(v17_tx_state_t *) v17_tx_init(v17_tx_state_t *s, int bit_rate, int
     }
     if (s == NULL)
     {
-        if ((s = (v17_tx_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (v17_tx_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -473,7 +474,7 @@ SPAN_DECLARE(int) v17_tx_release(v17_tx_state_t *s)
 
 SPAN_DECLARE(int) v17_tx_free(v17_tx_state_t *s)
 {
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index 65783eb73b8f60e5a3cb8d90227df81fa148b9ad..177ca88229c9d9085b26ff76e9278f63e4d9dfc5 100644 (file)
@@ -43,6 +43,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"
@@ -1113,7 +1114,7 @@ SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
 
     if (s == NULL)
     {
-        if ((s = (v18_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (v18_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -1204,7 +1205,7 @@ SPAN_DECLARE(int) v18_release(v18_state_t *s)
 
 SPAN_DECLARE(int) v18_free(v18_state_t *s)
 {
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index bb18b77b2649fc30027f97d2e1baed98ea517e1a..d7ecbe269aa61d2fa8ca5ee8d8755197fc8b4b19 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/logging.h"
 #include "spandsp/complex.h"
@@ -700,7 +701,7 @@ SPAN_DECLARE(v22bis_state_t *) v22bis_init(v22bis_state_t *s,
     }
     if (s == NULL)
     {
-        if ((s = (v22bis_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (v22bis_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -748,7 +749,7 @@ SPAN_DECLARE(int) v22bis_release(v22bis_state_t *s)
 
 SPAN_DECLARE(int) v22bis_free(v22bis_state_t *s)
 {
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index 5dabe1c6f06ec7c9142ee94178ea65bfa15e7091..0e49cf901b83d4bcead02bf23590492a0127fab2 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/math_fixed.h"
@@ -1087,7 +1088,7 @@ SPAN_DECLARE(v27ter_rx_state_t *) v27ter_rx_init(v27ter_rx_state_t *s, int bit_r
     }
     if (s == NULL)
     {
-        if ((s = (v27ter_rx_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (v27ter_rx_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -1110,7 +1111,7 @@ SPAN_DECLARE(int) v27ter_rx_release(v27ter_rx_state_t *s)
 
 SPAN_DECLARE(int) v27ter_rx_free(v27ter_rx_state_t *s)
 {
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index f1d7ce263d69d1638c9cfebecd1b8a06352c4d3a..1195b96d8f8a346e45e0f07c23edeae9a8d25166 100644 (file)
@@ -42,6 +42,7 @@
 #include "floating_fudge.h"
 
 #include "spandsp/telephony.h"
+#include "spandsp/alloc.h"
 #include "spandsp/fast_convert.h"
 #include "spandsp/logging.h"
 #include "spandsp/complex.h"
@@ -404,7 +405,7 @@ SPAN_DECLARE(v27ter_tx_state_t *) v27ter_tx_init(v27ter_tx_state_t *s, int bit_r
     }
     if (s == NULL)
     {
-        if ((s = (v27ter_tx_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (v27ter_tx_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -427,7 +428,7 @@ SPAN_DECLARE(int) v27ter_tx_release(v27ter_tx_state_t *s)
 
 SPAN_DECLARE(int) v27ter_tx_free(v27ter_tx_state_t *s)
 {
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index 3bb476726dcd16f9123df5c596bba449c05e0e72..a5520e92cdbdc9ac900f779193ae380751e61fe6 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/math_fixed.h"
@@ -1148,7 +1149,7 @@ SPAN_DECLARE(v29_rx_state_t *) v29_rx_init(v29_rx_state_t *s, int bit_rate, put_
     }
     if (s == NULL)
     {
-        if ((s = (v29_rx_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (v29_rx_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -1176,7 +1177,7 @@ SPAN_DECLARE(int) v29_rx_release(v29_rx_state_t *s)
 
 SPAN_DECLARE(int) v29_rx_free(v29_rx_state_t *s)
 {
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
index 3eac97e1bc235408668d05172799e39f1e965553..d6dbedf9ce0571cb1179e300e38e7015a838c759 100644 (file)
@@ -42,6 +42,7 @@
 #include "floating_fudge.h"
 
 #include "spandsp/telephony.h"
+#include "spandsp/alloc.h"
 #include "spandsp/fast_convert.h"
 #include "spandsp/logging.h"
 #include "spandsp/complex.h"
@@ -388,7 +389,7 @@ SPAN_DECLARE(v29_tx_state_t *) v29_tx_init(v29_tx_state_t *s, int bit_rate, int
     }
     if (s == NULL)
     {
-        if ((s = (v29_tx_state_t *) malloc(sizeof(*s))) == NULL)
+        if ((s = (v29_tx_state_t *) span_alloc(sizeof(*s))) == NULL)
             return NULL;
     }
     memset(s, 0, sizeof(*s));
@@ -411,7 +412,7 @@ SPAN_DECLARE(int) v29_tx_release(v29_tx_state_t *s)
 
 SPAN_DECLARE(int) v29_tx_free(v29_tx_state_t *s)
 {
-    free(s);
+    span_free(s);
     return 0;
 }
 /*- End of function --------------------------------------------------------*/