#include "asterisk/channel.h"
#include "asterisk/alaw.h"
#include "asterisk/ulaw.h"
+#include "asterisk/utils.h"
#define BUFFER_SIZE 8096 /* size for the translation buffers */
static struct ast_translator_pvt *alawtoulaw_new(void)
{
struct ulaw_encoder_pvt *tmp;
- tmp = malloc(sizeof(struct ulaw_encoder_pvt));
- if (tmp) {
- memset(tmp, 0, sizeof(*tmp));
+
+ if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
tmp->tail = 0;
localusecnt++;
ast_update_use_count();
}
+
return (struct ast_translator_pvt *)tmp;
}
static struct ast_translator_pvt *ulawtoalaw_new(void)
{
struct alaw_encoder_pvt *tmp;
- tmp = malloc(sizeof(struct alaw_encoder_pvt));
- if (tmp) {
- memset(tmp, 0, sizeof(*tmp));
+
+ if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
localusecnt++;
ast_update_use_count();
tmp->tail = 0;
}
+
return (struct ast_translator_pvt *)tmp;
}
#include "asterisk/options.h"
#include "asterisk/translate.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 */
static struct ast_translator_pvt *adpcmtolin_new(void)
{
struct adpcm_decoder_pvt *tmp;
- tmp = malloc(sizeof(struct adpcm_decoder_pvt));
- if (tmp) {
- memset(tmp, 0, sizeof(*tmp));
+
+ if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
tmp->tail = 0;
plc_init(&tmp->plc);
localusecnt++;
ast_update_use_count();
}
+
return (struct ast_translator_pvt *)tmp;
}
static struct ast_translator_pvt *lintoadpcm_new(void)
{
struct adpcm_encoder_pvt *tmp;
- tmp = malloc(sizeof(struct adpcm_encoder_pvt));
- if (tmp) {
- memset(tmp, 0, sizeof(*tmp));
+
+ if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
localusecnt++;
ast_update_use_count();
tmp->tail = 0;
}
+
return (struct ast_translator_pvt *)tmp;
}
#include "asterisk/translate.h"
#include "asterisk/channel.h"
#include "asterisk/alaw.h"
+#include "asterisk/utils.h"
#define BUFFER_SIZE 8096 /* size for the translation buffers */
static struct ast_translator_pvt *alawtolin_new(void)
{
struct alaw_decoder_pvt *tmp;
- tmp = malloc(sizeof(struct alaw_decoder_pvt));
- if (tmp) {
- memset(tmp, 0, sizeof(*tmp));
+
+ if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
tmp->tail = 0;
plc_init(&tmp->plc);
localusecnt++;
ast_update_use_count();
}
+
return (struct ast_translator_pvt *)tmp;
}
static struct ast_translator_pvt *lintoalaw_new(void)
{
struct alaw_encoder_pvt *tmp;
- tmp = malloc(sizeof(struct alaw_encoder_pvt));
- if (tmp) {
- memset(tmp, 0, sizeof(*tmp));
+
+ if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
localusecnt++;
ast_update_use_count();
tmp->tail = 0;
}
+
return (struct ast_translator_pvt *)tmp;
}
#include "asterisk/module.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
+#include "asterisk/utils.h"
#ifdef ANNEX_B
#include "g723.1b/typedef2.h"
static struct ast_translator_pvt *g723tolin_new(void)
{
- struct g723_decoder_pvt *tmp;
- tmp = malloc(sizeof(struct g723_decoder_pvt));
- if (tmp) {
+ struct g723_decoder_pvt *tmp;
+ if ((tmp = ast_malloc(sizeof(*tmp)))) {
Init_Decod(&tmp->dec);
Init_Dec_Cng(&tmp->dec);
tmp->tail = 0;
static struct ast_translator_pvt *lintog723_new(void)
{
- struct g723_encoder_pvt *tmp;
- tmp = malloc(sizeof(struct g723_encoder_pvt));
- if (tmp) {
+ struct g723_encoder_pvt *tmp;
+ if ((tmp = ast_malloc(sizeof(*tmp)))) {
Init_Coder(&tmp->cod);
/* Init Comfort Noise Functions */
if( UseVx ) {
#include "asterisk/options.h"
#include "asterisk/translate.h"
#include "asterisk/channel.h"
+#include "asterisk/utils.h"
#define WANT_ASM
#include "log2comp.h"
static struct ast_translator_pvt *
g726tolin_new (void)
{
- struct g726_decoder_pvt *tmp;
- tmp = malloc (sizeof (struct g726_decoder_pvt));
- if (tmp)
+ struct g726_decoder_pvt *tmp;
+ if ((tmp = ast_calloc(1, sizeof(*tmp))))
{
- memset(tmp, 0, sizeof(*tmp));
tmp->tail = 0;
plc_init(&tmp->plc);
localusecnt++;
static struct ast_translator_pvt *
lintog726_new (void)
{
- struct g726_encoder_pvt *tmp;
- tmp = malloc (sizeof (struct g726_encoder_pvt));
- if (tmp)
+ struct g726_encoder_pvt *tmp;
+ if ((tmp = ast_calloc(1, sizeof(*tmp))))
{
- memset(tmp, 0, sizeof(*tmp));
localusecnt++;
tmp->tail = 0;
g726_init_state(&tmp->g726);
#include "asterisk/module.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
+#include "asterisk/utils.h"
#ifdef USE_EXTERNAL_GSM_LIB
#include <gsm/gsm.h>
static struct ast_translator_pvt *gsm_new(void)
{
- struct gsm_coder_pvt *tmp;
- tmp = malloc(sizeof(struct gsm_coder_pvt));
- if (tmp) {
+ struct gsm_coder_pvt *tmp;
+ if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (!(tmp->gsm = gsm_create())) {
free(tmp);
tmp = NULL;
#include "asterisk/module.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
+#include "asterisk/utils.h"
#include "ilbc/iLBC_encode.h"
#include "ilbc/iLBC_decode.h"
static struct ast_translator_pvt *lintoilbc_new(void)
{
struct ilbc_coder_pvt *tmp;
- tmp = malloc(sizeof(struct ilbc_coder_pvt));
- if (tmp) {
+ if ((tmp = ast_malloc(sizeof(*tmp)))) {
/* Shut valgrind up */
memset(&tmp->enc, 0, sizeof(tmp->enc));
initEncode(&tmp->enc, ILBC_MS);
static struct ast_translator_pvt *ilbctolin_new(void)
{
- struct ilbc_coder_pvt *tmp;
- tmp = malloc(sizeof(struct ilbc_coder_pvt));
- if (tmp) {
+ struct ilbc_coder_pvt *tmp;
+ if ((tmp = ast_malloc(sizeof(*tmp)))) {
/* Shut valgrind up */
memset(&tmp->dec, 0, sizeof(tmp->dec));
initDecode(&tmp->dec, ILBC_MS, USE_ILBC_ENHANCER);
#include "asterisk/module.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
+#include "asterisk/utils.h"
#include "lpc10/lpc10.h"
static struct ast_translator_pvt *lpc10_enc_new(void)
{
- struct lpc10_coder_pvt *tmp;
- tmp = malloc(sizeof(struct lpc10_coder_pvt));
- if (tmp) {
+ struct lpc10_coder_pvt *tmp;
+ if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (!(tmp->lpc10.enc = create_lpc10_encoder_state())) {
free(tmp);
tmp = NULL;
static struct ast_translator_pvt *lpc10_dec_new(void)
{
- struct lpc10_coder_pvt *tmp;
- tmp = malloc(sizeof(struct lpc10_coder_pvt));
- if (tmp) {
+ struct lpc10_coder_pvt *tmp;
+ if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (!(tmp->lpc10.dec = create_lpc10_decoder_state())) {
free(tmp);
tmp = NULL;
#include "asterisk/options.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
+#include "asterisk/utils.h"
/* Sample frame data */
#include "slin_speex_ex.h"
static struct ast_translator_pvt *lintospeex_new(void)
{
- struct speex_coder_pvt *tmp;
- tmp = malloc(sizeof(struct speex_coder_pvt));
- if (tmp) {
+ struct speex_coder_pvt *tmp;
+ if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (!(tmp->speex = speex_encoder_init(&speex_nb_mode))) {
free(tmp);
tmp = NULL;
static struct ast_translator_pvt *speextolin_new(void)
{
- struct speex_coder_pvt *tmp;
- tmp = malloc(sizeof(struct speex_coder_pvt));
- if (tmp) {
+ struct speex_coder_pvt *tmp;
+ if ((tmp = ast_malloc(sizeof(*tmp)))) {
if (!(tmp->speex = speex_decoder_init(&speex_nb_mode))) {
free(tmp);
tmp = NULL;
#include "asterisk/translate.h"
#include "asterisk/channel.h"
#include "asterisk/ulaw.h"
+#include "asterisk/utils.h"
#define BUFFER_SIZE 8096 /* size for the translation buffers */
static struct ast_translator_pvt *ulawtolin_new(void)
{
struct ulaw_decoder_pvt *tmp;
- tmp = malloc(sizeof(struct ulaw_decoder_pvt));
- if (tmp) {
- memset(tmp, 0, sizeof(*tmp));
+
+ if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
tmp->tail = 0;
plc_init(&tmp->plc);
localusecnt++;
ast_update_use_count();
}
+
return (struct ast_translator_pvt *)tmp;
}
static struct ast_translator_pvt *lintoulaw_new(void)
{
struct ulaw_encoder_pvt *tmp;
- tmp = malloc(sizeof(struct ulaw_encoder_pvt));
- if (tmp) {
- memset(tmp, 0, sizeof(*tmp));
+
+ if ((tmp = ast_calloc(1, sizeof(*tmp)))) {
localusecnt++;
ast_update_use_count();
tmp->tail = 0;
}
+
return (struct ast_translator_pvt *)tmp;
}