[asterisk-commits] anthonyl: branch anthonyl/8295-calloc r48172 - in /team/anthonyl/8295-calloc:...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Nov 30 20:39:13 MST 2006


Author: anthonyl
Date: Thu Nov 30 21:39:13 2006
New Revision: 48172

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48172
Log:
exit() is wrong but it is still importent to make sure our allocations succeed

Modified:
    team/anthonyl/8295-calloc/apps/app_mixmonitor.c
    team/anthonyl/8295-calloc/main/ast_expr2.y

Modified: team/anthonyl/8295-calloc/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/8295-calloc/apps/app_mixmonitor.c?view=diff&rev=48172&r1=48171&r2=48172
==============================================================================
--- team/anthonyl/8295-calloc/apps/app_mixmonitor.c (original)
+++ team/anthonyl/8295-calloc/apps/app_mixmonitor.c Thu Nov 30 21:39:13 2006
@@ -234,7 +234,8 @@
 
 	/* Pre-allocate mixmonitor structure and spy */
 	if (!(mixmonitor = calloc(1, len))) {
-		exit(ENOMEM);
+		ast_log(LOG_WARNING, "failed to allocate %i bytes of memory\n");
+		return;
 	}
 
 	/* Copy over flags and channel name */

Modified: team/anthonyl/8295-calloc/main/ast_expr2.y
URL: http://svn.digium.com/view/asterisk/team/anthonyl/8295-calloc/main/ast_expr2.y?view=diff&rev=48172&r1=48171&r2=48172
==============================================================================
--- team/anthonyl/8295-calloc/main/ast_expr2.y (original)
+++ team/anthonyl/8295-calloc/main/ast_expr2.y Thu Nov 30 21:39:13 2006
@@ -172,7 +172,7 @@
 
 %%
 
-start: expr { ((struct parse_io *)parseio)->val = (struct val*) calloc(1, sizeof(struct val)); if (! ((struct parse_io*) parseio)->val) exit(ENOMEM);
+start: expr { ((struct parse_io *)parseio)->val = (struct val*) calloc(1, sizeof(struct val)); if (! ((struct parse_io*) parseio)->val) {  ast_log(LOG_WARNING, "failed memory allocation\n"); return; };
               ((struct parse_io *)parseio)->val->type = $1->type;
               if( $1->type == AST_EXPR_integer )
 				  ((struct parse_io *)parseio)->val->u.i = $1->u.i;
@@ -180,7 +180,7 @@
 				  ((struct parse_io *)parseio)->val->u.s = $1->u.s; 
 			  free($1);
 			}
-	| {/* nothing */ ((struct parse_io *)parseio)->val = (struct val*) calloc(1, sizeof(struct val)); if (!((struct parse_io*) parseio)->val) exit(ENOMEM);
+	| {/* nothing */ ((struct parse_io *)parseio)->val = (struct val*) calloc(1, sizeof(struct val)); if (!((struct parse_io*) parseio)->val) { ast_log(LOG_WARNING, "failed to memory allocation\n"); return; } ;
               ((struct parse_io *)parseio)->val->type = AST_EXPR_string;
 			  ((struct parse_io *)parseio)->val->u.s = strdup(""); if (! ((struct parse_io*) parseio)->val->u.s) exit(ENOMEM); 
 			}
@@ -440,7 +440,7 @@
 	char out[4096];
 	FILE *infile;
 	
-	if( !argv[1] )
+	if( !argv[1] ) 
 		exit(20);
 	
 	if( access(argv[1],F_OK)== 0 )



More information about the asterisk-commits mailing list