diff --git a/libs/spandsp/src/fsk.c b/libs/spandsp/src/fsk.c index 2c1d326d84..7e6619a58f 100644 --- a/libs/spandsp/src/fsk.c +++ b/libs/spandsp/src/fsk.c @@ -42,6 +42,7 @@ #include #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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/hdlc.c b/libs/spandsp/src/hdlc.c index 7733aa8280..3efaf3810e 100644 --- a/libs/spandsp/src/hdlc.c +++ b/libs/spandsp/src/hdlc.c @@ -35,6 +35,7 @@ #include #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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/ima_adpcm.c b/libs/spandsp/src/ima_adpcm.c index 6c4cc16370..fbd59df621 100644 --- a/libs/spandsp/src/ima_adpcm.c +++ b/libs/spandsp/src/ima_adpcm.c @@ -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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/image_translate.c b/libs/spandsp/src/image_translate.c index b504ca9074..ef30f6f4d4 100644 --- a/libs/spandsp/src/image_translate.c +++ b/libs/spandsp/src/image_translate.c @@ -52,6 +52,7 @@ #include #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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/modem_echo.c b/libs/spandsp/src/modem_echo.c index 59bf57b544..622c201279 100644 --- a/libs/spandsp/src/modem_echo.c +++ b/libs/spandsp/src/modem_echo.c @@ -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)); diff --git a/libs/spandsp/src/t31.c b/libs/spandsp/src/t31.c index 6a9f08d382..9993a7a521 100644 --- a/libs/spandsp/src/t31.c +++ b/libs/spandsp/src/t31.c @@ -51,6 +51,7 @@ #include #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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t38_core.c b/libs/spandsp/src/t38_core.c index ae6526f7e8..922e8a372a 100644 --- a/libs/spandsp/src/t38_core.c +++ b/libs/spandsp/src/t38_core.c @@ -47,6 +47,7 @@ #include #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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t38_gateway.c b/libs/spandsp/src/t38_gateway.c index 7656332e80..7078a37908 100644 --- a/libs/spandsp/src/t38_gateway.c +++ b/libs/spandsp/src/t38_gateway.c @@ -50,6 +50,7 @@ #include #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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t38_non_ecm_buffer.c b/libs/spandsp/src/t38_non_ecm_buffer.c index cc339a0581..bd63c419f2 100644 --- a/libs/spandsp/src/t38_non_ecm_buffer.c +++ b/libs/spandsp/src/t38_non_ecm_buffer.c @@ -46,6 +46,7 @@ #include #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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t38_terminal.c b/libs/spandsp/src/t38_terminal.c index 66938d8d24..02a9369f35 100644 --- a/libs/spandsp/src/t38_terminal.c +++ b/libs/spandsp/src/t38_terminal.c @@ -46,6 +46,7 @@ #include #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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t42.c b/libs/spandsp/src/t42.c index 8d0023f7d7..5a00a4121e 100644 --- a/libs/spandsp/src/t42.c +++ b/libs/spandsp/src/t42.c @@ -50,6 +50,7 @@ #include #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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t43.c b/libs/spandsp/src/t43.c index b0e1abffb9..9e2ee76be2 100644 --- a/libs/spandsp/src/t43.c +++ b/libs/spandsp/src/t43.c @@ -44,6 +44,7 @@ #include #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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t4_t6_decode.c b/libs/spandsp/src/t4_t6_decode.c index c347dfd19a..219a0bafb8 100644 --- a/libs/spandsp/src/t4_t6_decode.c +++ b/libs/spandsp/src/t4_t6_decode.c @@ -79,6 +79,7 @@ #include #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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t4_t6_encode.c b/libs/spandsp/src/t4_t6_encode.c index 4ed063e063..fde78f4827 100644 --- a/libs/spandsp/src/t4_t6_encode.c +++ b/libs/spandsp/src/t4_t6_encode.c @@ -76,6 +76,7 @@ #include #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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v17tx.c b/libs/spandsp/src/v17tx.c index fe361d7744..b4f9f3e80a 100644 --- a/libs/spandsp/src/v17tx.c +++ b/libs/spandsp/src/v17tx.c @@ -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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v18.c b/libs/spandsp/src/v18.c index 65783eb73b..177ca88229 100644 --- a/libs/spandsp/src/v18.c +++ b/libs/spandsp/src/v18.c @@ -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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v22bis_tx.c b/libs/spandsp/src/v22bis_tx.c index bb18b77b26..d7ecbe269a 100644 --- a/libs/spandsp/src/v22bis_tx.c +++ b/libs/spandsp/src/v22bis_tx.c @@ -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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v27ter_rx.c b/libs/spandsp/src/v27ter_rx.c index 5dabe1c6f0..0e49cf901b 100644 --- a/libs/spandsp/src/v27ter_rx.c +++ b/libs/spandsp/src/v27ter_rx.c @@ -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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v27ter_tx.c b/libs/spandsp/src/v27ter_tx.c index f1d7ce263d..1195b96d8f 100644 --- a/libs/spandsp/src/v27ter_tx.c +++ b/libs/spandsp/src/v27ter_tx.c @@ -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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v29rx.c b/libs/spandsp/src/v29rx.c index 3bb476726d..a5520e92cd 100644 --- a/libs/spandsp/src/v29rx.c +++ b/libs/spandsp/src/v29rx.c @@ -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 --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v29tx.c b/libs/spandsp/src/v29tx.c index 3eac97e1bc..d6dbedf9ce 100644 --- a/libs/spandsp/src/v29tx.c +++ b/libs/spandsp/src/v29tx.c @@ -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 --------------------------------------------------------*/