conversions to use allocation wrappers (issue #6277)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@8381 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2006-01-21 08:45:39 +00:00
parent 2499926195
commit fbdc8ce317
10 changed files with 55 additions and 58 deletions

View File

@@ -41,6 +41,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/channel.h" #include "asterisk/channel.h"
#include "asterisk/alaw.h" #include "asterisk/alaw.h"
#include "asterisk/ulaw.h" #include "asterisk/ulaw.h"
#include "asterisk/utils.h"
#define BUFFER_SIZE 8096 /* size for the translation buffers */ #define BUFFER_SIZE 8096 /* size for the translation buffers */
@@ -83,26 +84,26 @@ struct ulaw_encoder_pvt
static struct ast_translator_pvt *alawtoulaw_new(void) static struct ast_translator_pvt *alawtoulaw_new(void)
{ {
struct ulaw_encoder_pvt *tmp; struct ulaw_encoder_pvt *tmp;
tmp = malloc(sizeof(struct ulaw_encoder_pvt));
if (tmp) { if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
memset(tmp, 0, sizeof(*tmp));
tmp->tail = 0; tmp->tail = 0;
localusecnt++; localusecnt++;
ast_update_use_count(); ast_update_use_count();
} }
return (struct ast_translator_pvt *)tmp; return (struct ast_translator_pvt *)tmp;
} }
static struct ast_translator_pvt *ulawtoalaw_new(void) static struct ast_translator_pvt *ulawtoalaw_new(void)
{ {
struct alaw_encoder_pvt *tmp; struct alaw_encoder_pvt *tmp;
tmp = malloc(sizeof(struct alaw_encoder_pvt));
if (tmp) { if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
memset(tmp, 0, sizeof(*tmp));
localusecnt++; localusecnt++;
ast_update_use_count(); ast_update_use_count();
tmp->tail = 0; tmp->tail = 0;
} }
return (struct ast_translator_pvt *)tmp; return (struct ast_translator_pvt *)tmp;
} }

View File

@@ -45,6 +45,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/options.h" #include "asterisk/options.h"
#include "asterisk/translate.h" #include "asterisk/translate.h"
#include "asterisk/channel.h" #include "asterisk/channel.h"
#include "asterisk/utils.h"
/* define NOT_BLI to use a faster but not bit-level identical version */ /* define NOT_BLI to use a faster but not bit-level identical version */
/* #define NOT_BLI */ /* #define NOT_BLI */
@@ -268,14 +269,14 @@ struct adpcm_decoder_pvt
static struct ast_translator_pvt *adpcmtolin_new(void) static struct ast_translator_pvt *adpcmtolin_new(void)
{ {
struct adpcm_decoder_pvt *tmp; struct adpcm_decoder_pvt *tmp;
tmp = malloc(sizeof(struct adpcm_decoder_pvt));
if (tmp) { if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
memset(tmp, 0, sizeof(*tmp));
tmp->tail = 0; tmp->tail = 0;
plc_init(&tmp->plc); plc_init(&tmp->plc);
localusecnt++; localusecnt++;
ast_update_use_count(); ast_update_use_count();
} }
return (struct ast_translator_pvt *)tmp; return (struct ast_translator_pvt *)tmp;
} }
@@ -293,13 +294,13 @@ static struct ast_translator_pvt *adpcmtolin_new(void)
static struct ast_translator_pvt *lintoadpcm_new(void) static struct ast_translator_pvt *lintoadpcm_new(void)
{ {
struct adpcm_encoder_pvt *tmp; struct adpcm_encoder_pvt *tmp;
tmp = malloc(sizeof(struct adpcm_encoder_pvt));
if (tmp) { if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
memset(tmp, 0, sizeof(*tmp));
localusecnt++; localusecnt++;
ast_update_use_count(); ast_update_use_count();
tmp->tail = 0; tmp->tail = 0;
} }
return (struct ast_translator_pvt *)tmp; return (struct ast_translator_pvt *)tmp;
} }

View File

@@ -42,6 +42,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/translate.h" #include "asterisk/translate.h"
#include "asterisk/channel.h" #include "asterisk/channel.h"
#include "asterisk/alaw.h" #include "asterisk/alaw.h"
#include "asterisk/utils.h"
#define BUFFER_SIZE 8096 /* size for the translation buffers */ #define BUFFER_SIZE 8096 /* size for the translation buffers */
@@ -94,14 +95,14 @@ struct alaw_decoder_pvt
static struct ast_translator_pvt *alawtolin_new(void) static struct ast_translator_pvt *alawtolin_new(void)
{ {
struct alaw_decoder_pvt *tmp; struct alaw_decoder_pvt *tmp;
tmp = malloc(sizeof(struct alaw_decoder_pvt));
if (tmp) { if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
memset(tmp, 0, sizeof(*tmp));
tmp->tail = 0; tmp->tail = 0;
plc_init(&tmp->plc); plc_init(&tmp->plc);
localusecnt++; localusecnt++;
ast_update_use_count(); ast_update_use_count();
} }
return (struct ast_translator_pvt *)tmp; return (struct ast_translator_pvt *)tmp;
} }
@@ -119,13 +120,13 @@ static struct ast_translator_pvt *alawtolin_new(void)
static struct ast_translator_pvt *lintoalaw_new(void) static struct ast_translator_pvt *lintoalaw_new(void)
{ {
struct alaw_encoder_pvt *tmp; struct alaw_encoder_pvt *tmp;
tmp = malloc(sizeof(struct alaw_encoder_pvt));
if (tmp) { if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
memset(tmp, 0, sizeof(*tmp));
localusecnt++; localusecnt++;
ast_update_use_count(); ast_update_use_count();
tmp->tail = 0; tmp->tail = 0;
} }
return (struct ast_translator_pvt *)tmp; return (struct ast_translator_pvt *)tmp;
} }

View File

@@ -50,6 +50,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/module.h" #include "asterisk/module.h"
#include "asterisk/logger.h" #include "asterisk/logger.h"
#include "asterisk/channel.h" #include "asterisk/channel.h"
#include "asterisk/utils.h"
#ifdef ANNEX_B #ifdef ANNEX_B
#include "g723.1b/typedef2.h" #include "g723.1b/typedef2.h"
@@ -113,9 +114,8 @@ struct g723_decoder_pvt {
static struct ast_translator_pvt *g723tolin_new(void) static struct ast_translator_pvt *g723tolin_new(void)
{ {
struct g723_decoder_pvt *tmp; struct g723_decoder_pvt *tmp;
tmp = malloc(sizeof(struct g723_decoder_pvt)); if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (tmp) {
Init_Decod(&tmp->dec); Init_Decod(&tmp->dec);
Init_Dec_Cng(&tmp->dec); Init_Dec_Cng(&tmp->dec);
tmp->tail = 0; tmp->tail = 0;
@@ -157,9 +157,8 @@ static struct ast_frame *g723tolin_sample(void)
static struct ast_translator_pvt *lintog723_new(void) static struct ast_translator_pvt *lintog723_new(void)
{ {
struct g723_encoder_pvt *tmp; struct g723_encoder_pvt *tmp;
tmp = malloc(sizeof(struct g723_encoder_pvt)); if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (tmp) {
Init_Coder(&tmp->cod); Init_Coder(&tmp->cod);
/* Init Comfort Noise Functions */ /* Init Comfort Noise Functions */
if( UseVx ) { if( UseVx ) {

View File

@@ -45,6 +45,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/options.h" #include "asterisk/options.h"
#include "asterisk/translate.h" #include "asterisk/translate.h"
#include "asterisk/channel.h" #include "asterisk/channel.h"
#include "asterisk/utils.h"
#define WANT_ASM #define WANT_ASM
#include "log2comp.h" #include "log2comp.h"
@@ -734,11 +735,9 @@ struct g726_decoder_pvt
static struct ast_translator_pvt * static struct ast_translator_pvt *
g726tolin_new (void) g726tolin_new (void)
{ {
struct g726_decoder_pvt *tmp; struct g726_decoder_pvt *tmp;
tmp = malloc (sizeof (struct g726_decoder_pvt)); if ((tmp = ast_calloc(1, sizeof(*tmp))))
if (tmp)
{ {
memset(tmp, 0, sizeof(*tmp));
tmp->tail = 0; tmp->tail = 0;
plc_init(&tmp->plc); plc_init(&tmp->plc);
localusecnt++; localusecnt++;
@@ -762,11 +761,9 @@ g726tolin_new (void)
static struct ast_translator_pvt * static struct ast_translator_pvt *
lintog726_new (void) lintog726_new (void)
{ {
struct g726_encoder_pvt *tmp; struct g726_encoder_pvt *tmp;
tmp = malloc (sizeof (struct g726_encoder_pvt)); if ((tmp = ast_calloc(1, sizeof(*tmp))))
if (tmp)
{ {
memset(tmp, 0, sizeof(*tmp));
localusecnt++; localusecnt++;
tmp->tail = 0; tmp->tail = 0;
g726_init_state(&tmp->g726); g726_init_state(&tmp->g726);

View File

@@ -44,6 +44,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/module.h" #include "asterisk/module.h"
#include "asterisk/logger.h" #include "asterisk/logger.h"
#include "asterisk/channel.h" #include "asterisk/channel.h"
#include "asterisk/utils.h"
#ifdef USE_EXTERNAL_GSM_LIB #ifdef USE_EXTERNAL_GSM_LIB
#include <gsm/gsm.h> #include <gsm/gsm.h>
@@ -81,9 +82,8 @@ struct ast_translator_pvt {
static struct ast_translator_pvt *gsm_new(void) static struct ast_translator_pvt *gsm_new(void)
{ {
struct gsm_coder_pvt *tmp; struct gsm_coder_pvt *tmp;
tmp = malloc(sizeof(struct gsm_coder_pvt)); if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (tmp) {
if (!(tmp->gsm = gsm_create())) { if (!(tmp->gsm = gsm_create())) {
free(tmp); free(tmp);
tmp = NULL; tmp = NULL;

View File

@@ -41,6 +41,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/module.h" #include "asterisk/module.h"
#include "asterisk/logger.h" #include "asterisk/logger.h"
#include "asterisk/channel.h" #include "asterisk/channel.h"
#include "asterisk/utils.h"
#include "ilbc/iLBC_encode.h" #include "ilbc/iLBC_encode.h"
#include "ilbc/iLBC_decode.h" #include "ilbc/iLBC_decode.h"
@@ -76,8 +77,7 @@ struct ast_translator_pvt {
static struct ast_translator_pvt *lintoilbc_new(void) static struct ast_translator_pvt *lintoilbc_new(void)
{ {
struct ilbc_coder_pvt *tmp; struct ilbc_coder_pvt *tmp;
tmp = malloc(sizeof(struct ilbc_coder_pvt)); if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (tmp) {
/* Shut valgrind up */ /* Shut valgrind up */
memset(&tmp->enc, 0, sizeof(tmp->enc)); memset(&tmp->enc, 0, sizeof(tmp->enc));
initEncode(&tmp->enc, ILBC_MS); initEncode(&tmp->enc, ILBC_MS);
@@ -89,9 +89,8 @@ static struct ast_translator_pvt *lintoilbc_new(void)
static struct ast_translator_pvt *ilbctolin_new(void) static struct ast_translator_pvt *ilbctolin_new(void)
{ {
struct ilbc_coder_pvt *tmp; struct ilbc_coder_pvt *tmp;
tmp = malloc(sizeof(struct ilbc_coder_pvt)); if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (tmp) {
/* Shut valgrind up */ /* Shut valgrind up */
memset(&tmp->dec, 0, sizeof(tmp->dec)); memset(&tmp->dec, 0, sizeof(tmp->dec));
initDecode(&tmp->dec, ILBC_MS, USE_ILBC_ENHANCER); initDecode(&tmp->dec, ILBC_MS, USE_ILBC_ENHANCER);

View File

@@ -45,6 +45,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/module.h" #include "asterisk/module.h"
#include "asterisk/logger.h" #include "asterisk/logger.h"
#include "asterisk/channel.h" #include "asterisk/channel.h"
#include "asterisk/utils.h"
#include "lpc10/lpc10.h" #include "lpc10/lpc10.h"
@@ -87,9 +88,8 @@ struct ast_translator_pvt {
static struct ast_translator_pvt *lpc10_enc_new(void) static struct ast_translator_pvt *lpc10_enc_new(void)
{ {
struct lpc10_coder_pvt *tmp; struct lpc10_coder_pvt *tmp;
tmp = malloc(sizeof(struct lpc10_coder_pvt)); if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (tmp) {
if (!(tmp->lpc10.enc = create_lpc10_encoder_state())) { if (!(tmp->lpc10.enc = create_lpc10_encoder_state())) {
free(tmp); free(tmp);
tmp = NULL; tmp = NULL;
@@ -103,9 +103,8 @@ static struct ast_translator_pvt *lpc10_enc_new(void)
static struct ast_translator_pvt *lpc10_dec_new(void) static struct ast_translator_pvt *lpc10_dec_new(void)
{ {
struct lpc10_coder_pvt *tmp; struct lpc10_coder_pvt *tmp;
tmp = malloc(sizeof(struct lpc10_coder_pvt)); if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (tmp) {
if (!(tmp->lpc10.dec = create_lpc10_decoder_state())) { if (!(tmp->lpc10.dec = create_lpc10_decoder_state())) {
free(tmp); free(tmp);
tmp = NULL; tmp = NULL;

View File

@@ -75,6 +75,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/options.h" #include "asterisk/options.h"
#include "asterisk/logger.h" #include "asterisk/logger.h"
#include "asterisk/channel.h" #include "asterisk/channel.h"
#include "asterisk/utils.h"
/* Sample frame data */ /* Sample frame data */
#include "slin_speex_ex.h" #include "slin_speex_ex.h"
@@ -111,9 +112,8 @@ struct ast_translator_pvt {
static struct ast_translator_pvt *lintospeex_new(void) static struct ast_translator_pvt *lintospeex_new(void)
{ {
struct speex_coder_pvt *tmp; struct speex_coder_pvt *tmp;
tmp = malloc(sizeof(struct speex_coder_pvt)); if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (tmp) {
if (!(tmp->speex = speex_encoder_init(&speex_nb_mode))) { if (!(tmp->speex = speex_encoder_init(&speex_nb_mode))) {
free(tmp); free(tmp);
tmp = NULL; tmp = NULL;
@@ -158,9 +158,8 @@ static struct ast_translator_pvt *lintospeex_new(void)
static struct ast_translator_pvt *speextolin_new(void) static struct ast_translator_pvt *speextolin_new(void)
{ {
struct speex_coder_pvt *tmp; struct speex_coder_pvt *tmp;
tmp = malloc(sizeof(struct speex_coder_pvt)); if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (tmp) {
if (!(tmp->speex = speex_decoder_init(&speex_nb_mode))) { if (!(tmp->speex = speex_decoder_init(&speex_nb_mode))) {
free(tmp); free(tmp);
tmp = NULL; tmp = NULL;

View File

@@ -42,6 +42,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/translate.h" #include "asterisk/translate.h"
#include "asterisk/channel.h" #include "asterisk/channel.h"
#include "asterisk/ulaw.h" #include "asterisk/ulaw.h"
#include "asterisk/utils.h"
#define BUFFER_SIZE 8096 /* size for the translation buffers */ #define BUFFER_SIZE 8096 /* size for the translation buffers */
@@ -96,14 +97,14 @@ struct ulaw_decoder_pvt
static struct ast_translator_pvt *ulawtolin_new(void) static struct ast_translator_pvt *ulawtolin_new(void)
{ {
struct ulaw_decoder_pvt *tmp; struct ulaw_decoder_pvt *tmp;
tmp = malloc(sizeof(struct ulaw_decoder_pvt));
if (tmp) { if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
memset(tmp, 0, sizeof(*tmp));
tmp->tail = 0; tmp->tail = 0;
plc_init(&tmp->plc); plc_init(&tmp->plc);
localusecnt++; localusecnt++;
ast_update_use_count(); ast_update_use_count();
} }
return (struct ast_translator_pvt *)tmp; return (struct ast_translator_pvt *)tmp;
} }
@@ -121,13 +122,13 @@ static struct ast_translator_pvt *ulawtolin_new(void)
static struct ast_translator_pvt *lintoulaw_new(void) static struct ast_translator_pvt *lintoulaw_new(void)
{ {
struct ulaw_encoder_pvt *tmp; struct ulaw_encoder_pvt *tmp;
tmp = malloc(sizeof(struct ulaw_encoder_pvt));
if (tmp) { if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
memset(tmp, 0, sizeof(*tmp));
localusecnt++; localusecnt++;
ast_update_use_count(); ast_update_use_count();
tmp->tail = 0; tmp->tail = 0;
} }
return (struct ast_translator_pvt *)tmp; return (struct ast_translator_pvt *)tmp;
} }