summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2006-01-03 16:39:37 +0000
committerKevin P. Fleming <kpfleming@digium.com>2006-01-03 16:39:37 +0000
commit142ef858a5014521c4f260a64c13a916af068d27 (patch)
treec90aec7a251920ac4f34bfe5c44643e52b6778b8
parent1e6ada5f6836e10b5f1e9225dd44faca3f04071d (diff)
Merged revisions 7736 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r7736 | kpfleming | 2006-01-03 10:34:12 -0600 (Tue, 03 Jan 2006) | 2 lines don't leak memory for (most) expression evaluations ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7737 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--ast_expr2.fl36
-rw-r--r--ast_expr2f.c36
2 files changed, 36 insertions, 36 deletions
diff --git a/ast_expr2.fl b/ast_expr2.fl
index 7a54ed36b..9e198e7b2 100644
--- a/ast_expr2.fl
+++ b/ast_expr2.fl
@@ -98,42 +98,42 @@ int ast_yyerror(const char *, YYLTYPE *, struct parse_io *); /* likewise */
int ast_expr(char *expr, char *buf, int length)
{
- struct parse_io *io;
+ struct parse_io io;
+ int return_value = 0;
- io = calloc(sizeof(struct parse_io),1);
- io->string = expr; /* to pass to the error routine */
+ memset(&io, 0, sizeof(io));
+ io.string = expr; /* to pass to the error routine */
- ast_yylex_init(&io->scanner);
+ ast_yylex_init(&io.scanner);
- ast_yy_scan_string(expr, io->scanner);
+ ast_yy_scan_string(expr, io.scanner);
- ast_yyparse ((void *) io);
+ ast_yyparse ((void *) &io);
- ast_yylex_destroy(io->scanner);
+ ast_yylex_destroy(io.scanner);
- if (io->val == NULL) {
+ if (!io.val) {
if (length > 1) {
strcpy(buf, "0");
- return 1;
+ return_value = 1;
}
} else {
- if (io->val->type == AST_EXPR_integer) {
+ if (io.val->type == AST_EXPR_integer) {
int res_length;
- res_length = snprintf(buf, length, "%ld", (long int) io->val->u.i);
- return res_length <= length ? res_length : length;
+ res_length = snprintf(buf, length, "%ld", (long int) io.val->u.i);
+ return_value = (res_length <= length) ? res_length : length;
} else {
#ifdef STANDALONE
- strncpy(buf, io->val->u.s, length - 1);
+ strncpy(buf, io.val->u.s, length - 1);
#else /* !STANDALONE */
- ast_copy_string(buf, io->val->u.s, length);
+ ast_copy_string(buf, io.val->u.s, length);
#endif /* STANDALONE */
- return strlen(buf);
+ return_value = strlen(buf);
}
- free(io->val);
+ free(io.val);
}
- free(io);
- return 0;
+ return return_value;
}
int ast_yyerror (const char *s, yyltype *loc, struct parse_io *parseio )
diff --git a/ast_expr2f.c b/ast_expr2f.c
index defaa100c..71f62ee0b 100644
--- a/ast_expr2f.c
+++ b/ast_expr2f.c
@@ -2562,42 +2562,42 @@ int ast_yyerror(const char *, YYLTYPE *, struct parse_io *); /* likewise */
int ast_expr(char *expr, char *buf, int length)
{
- struct parse_io *io;
+ struct parse_io io;
+ int return_value = 0;
- io = calloc(sizeof(struct parse_io),1);
- io->string = expr; /* to pass to the error routine */
+ memset(&io, 0, sizeof(io));
+ io.string = expr; /* to pass to the error routine */
- ast_yylex_init(&io->scanner);
+ ast_yylex_init(&io.scanner);
- ast_yy_scan_string(expr, io->scanner);
+ ast_yy_scan_string(expr, io.scanner);
- ast_yyparse ((void *) io);
+ ast_yyparse ((void *) &io);
- ast_yylex_destroy(io->scanner);
+ ast_yylex_destroy(io.scanner);
- if (io->val == NULL) {
+ if (!io.val) {
if (length > 1) {
strcpy(buf, "0");
- return 1;
+ return_value = 1;
}
} else {
- if (io->val->type == AST_EXPR_integer) {
+ if (io.val->type == AST_EXPR_integer) {
int res_length;
- res_length = snprintf(buf, length, "%ld", (long int) io->val->u.i);
- return res_length <= length ? res_length : length;
+ res_length = snprintf(buf, length, "%ld", (long int) io.val->u.i);
+ return_value = (res_length <= length) ? res_length : length;
} else {
#ifdef STANDALONE
- strncpy(buf, io->val->u.s, length - 1);
+ strncpy(buf, io.val->u.s, length - 1);
#else /* !STANDALONE */
- ast_copy_string(buf, io->val->u.s, length);
+ ast_copy_string(buf, io.val->u.s, length);
#endif /* STANDALONE */
- return strlen(buf);
+ return_value = strlen(buf);
}
- free(io->val);
+ free(io.val);
}
- free(io);
- return 0;
+ return return_value;
}
int ast_yyerror (const char *s, yyltype *loc, struct parse_io *parseio )