use ast_calloc for memory allocations

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@22903 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Luigi Rizzo
2006-04-27 17:43:49 +00:00
parent 73ea5316b5
commit 776a3da1a7
3 changed files with 266 additions and 264 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -115,7 +115,7 @@
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 50 "ael.y" #line 51 "ael.y"
typedef union YYSTYPE { typedef union YYSTYPE {
char *str; char *str;
struct pval *pval; struct pval *pval;

View File

@@ -25,6 +25,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "asterisk/logger.h" #include "asterisk/logger.h"
#include "asterisk/utils.h" /* ast_calloc() */
#include "asterisk/ael_structs.h" #include "asterisk/ael_structs.h"
static pval *npval(pvaltype type, int first_line, int last_line, static pval *npval(pvaltype type, int first_line, int last_line,
@@ -437,7 +438,7 @@ statement : LC statements RC {
tot++; /* for a sep like a comma */ tot++; /* for a sep like a comma */
} }
tot+=4; /* for safety */ tot+=4; /* for safety */
bufx = (char *)malloc(tot); bufx = ast_calloc(1, tot);
strcpy(bufx,$1->u1.str); strcpy(bufx,$1->u1.str);
strcat(bufx,"("); strcat(bufx,"(");
/* XXX need to advance the pointer or the loop is very inefficient */ /* XXX need to advance the pointer or the loop is very inefficient */
@@ -803,7 +804,7 @@ static char *ael_token_subst(char *mess)
} }
len++; len++;
} }
res = (char*)malloc(len+1); res = ast_calloc(1, len+1);
res[0] = 0; res[0] = 0;
s = res; s = res;
for (p=mess; *p;) { for (p=mess; *p;) {
@@ -843,7 +844,7 @@ static struct pval *npval(pvaltype type, int first_line, int last_line,
int first_column, int last_column) int first_column, int last_column)
{ {
extern char *my_file; extern char *my_file;
pval *z = (pval *)calloc(sizeof(struct pval),1); pval *z = ast_calloc(1, sizeof(struct pval));
z->type = type; z->type = type;
z->startline = first_line; z->startline = first_line;
z->endline = last_line; z->endline = last_line;