[asterisk-commits] kmoore: trunk r370655 - in /trunk: ./ addons/ apps/ cdr/ channels/ funcs/ inc...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 31 15:22:01 CDT 2012


Author: kmoore
Date: Tue Jul 31 15:21:43 2012
New Revision: 370655

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=370655
Log:
Clean up and ensure proper usage of alloca()

This replaces all calls to alloca() with ast_alloca() which calls gcc's
__builtin_alloca() to avoid BSD semantics and removes all NULL checks
on memory allocated via ast_alloca() and ast_strdupa().

(closes issue ASTERISK-20125)
Review: https://reviewboard.asterisk.org/r/2032/
........

Merged revisions 370642 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 370643 from http://svn.asterisk.org/svn/asterisk/branches/10

Modified:
    trunk/   (props changed)
    trunk/addons/app_mysql.c
    trunk/addons/chan_mobile.c
    trunk/addons/res_config_mysql.c
    trunk/apps/app_dictate.c
    trunk/apps/app_directed_pickup.c
    trunk/apps/app_festival.c
    trunk/apps/app_getcpeid.c
    trunk/apps/app_macro.c
    trunk/apps/app_meetme.c
    trunk/apps/app_minivm.c
    trunk/apps/app_mixmonitor.c
    trunk/apps/app_osplookup.c
    trunk/apps/app_sms.c
    trunk/apps/app_voicemail.c
    trunk/apps/app_while.c
    trunk/cdr/cdr_pgsql.c
    trunk/channels/chan_alsa.c
    trunk/channels/chan_dahdi.c
    trunk/channels/chan_gtalk.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_jingle.c
    trunk/channels/chan_sip.c
    trunk/channels/sig_analog.c
    trunk/channels/sig_pri.c
    trunk/channels/sig_ss7.c
    trunk/funcs/func_channel.c
    trunk/funcs/func_cut.c
    trunk/funcs/func_global.c
    trunk/funcs/func_logic.c
    trunk/funcs/func_strings.c
    trunk/include/asterisk/strings.h
    trunk/include/asterisk/utils.h
    trunk/main/app.c
    trunk/main/asterisk.c
    trunk/main/astmm.c
    trunk/main/callerid.c
    trunk/main/channel.c
    trunk/main/config.c
    trunk/main/db.c
    trunk/main/dsp.c
    trunk/main/event.c
    trunk/main/features.c
    trunk/main/file.c
    trunk/main/http.c
    trunk/main/logger.c
    trunk/main/manager.c
    trunk/main/pbx.c
    trunk/main/say.c
    trunk/main/strcompat.c
    trunk/main/tcptls.c
    trunk/main/threadstorage.c
    trunk/main/utils.c
    trunk/pbx/pbx_ael.c
    trunk/pbx/pbx_dundi.c
    trunk/pbx/pbx_lua.c
    trunk/pbx/pbx_realtime.c
    trunk/pbx/pbx_spool.c
    trunk/res/ael/pval.c
    trunk/res/res_agi.c
    trunk/res/res_config_pgsql.c
    trunk/res/res_http_websocket.c
    trunk/res/res_jabber.c
    trunk/tests/test_linkedlists.c
    trunk/utils/extconf.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.

Modified: trunk/addons/app_mysql.c
URL: http://svnview.digium.com/svn/asterisk/trunk/addons/app_mysql.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/addons/app_mysql.c (original)
+++ trunk/addons/app_mysql.c Tue Jul 31 15:21:43 2012
@@ -295,7 +295,7 @@
 	AST_NONSTANDARD_APP_ARGS(args, data, ' ');
 
 	if (args.argc == 3) {
-		var = alloca(6 + strlen(args.variable) + 1);
+		var = ast_alloca(6 + strlen(args.variable) + 1);
 		sprintf(var, "MYSQL_%s", args.variable);
 
 		/* Make the parameter case-insensitive */

Modified: trunk/addons/chan_mobile.c
URL: http://svnview.digium.com/svn/asterisk/trunk/addons/chan_mobile.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/addons/chan_mobile.c (original)
+++ trunk/addons/chan_mobile.c Tue Jul 31 15:21:43 2012
@@ -557,7 +557,7 @@
 	max_rsp = 255;
 	flags = IREQ_CACHE_FLUSH;
 
-	ii = alloca(max_rsp * sizeof(inquiry_info));
+	ii = ast_alloca(max_rsp * sizeof(inquiry_info));
 	num_rsp = hci_inquiry(adapter->dev_id, len, max_rsp, NULL, &ii, flags);
 	if (num_rsp > 0) {
 		ast_cli(a->fd, FORMAT1, "Address", "Name", "Usable", "Type", "Port");

Modified: trunk/addons/res_config_mysql.c
URL: http://svnview.digium.com/svn/asterisk/trunk/addons/res_config_mysql.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/addons/res_config_mysql.c (original)
+++ trunk/addons/res_config_mysql.c Tue Jul 31 15:21:43 2012
@@ -144,7 +144,7 @@
 		if (for_write) {
 			whichdb = ast_strdupa(ptr + 1);
 		} else {
-			whichdb = alloca(ptr - database + 1);
+			whichdb = ast_alloca(ptr - database + 1);
 			strncpy(whichdb, database, ptr - database);
 			whichdb[ptr - database] = '\0';
 		}
@@ -467,7 +467,7 @@
 	}
 
 	initfield = ast_strdupa(newparam);
-	if (initfield && (op = strchr(initfield, ' '))) {
+	if ((op = strchr(initfield, ' '))) {
 		*op = '\0';
 	}
 

Modified: trunk/apps/app_dictate.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_dictate.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/apps/app_dictate.c (original)
+++ trunk/apps/app_dictate.c Tue Jul 31 15:21:43 2012
@@ -150,7 +150,7 @@
 		ast_mkdir(base, 0755);
 		len = strlen(base) + strlen(filein) + 2;
 		if (!path || len > maxlen) {
-			path = alloca(len);
+			path = ast_alloca(len);
 			memset(path, 0, len);
 			maxlen = len;
 		} else {

Modified: trunk/apps/app_directed_pickup.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_directed_pickup.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/apps/app_directed_pickup.c (original)
+++ trunk/apps/app_directed_pickup.c Tue Jul 31 15:21:43 2012
@@ -158,7 +158,7 @@
 		 * debugging.
 		 */
 		pickup_args.len = strlen(channame) + 1;
-		chkchan = alloca(pickup_args.len + 1);
+		chkchan = ast_alloca(pickup_args.len + 1);
 		strcpy(chkchan, channame);
 		strcat(chkchan, "-");
 		pickup_args.name = chkchan;

Modified: trunk/apps/app_festival.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_festival.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/apps/app_festival.c (original)
+++ trunk/apps/app_festival.c Tue Jul 31 15:21:43 2012
@@ -344,12 +344,12 @@
 		const char *endcmd = "\" 'file)(quit)\n";
 
 		strln = strlen(startcmd) + strlen(args.text) + strlen(endcmd) + 1;
-		newfestivalcommand = alloca(strln);
+		newfestivalcommand = ast_alloca(strln);
 		snprintf(newfestivalcommand, strln, "%s%s%s", startcmd, args.text, endcmd);
 		festivalcommand = newfestivalcommand;
 	} else { /* This else parses the festivalcommand that we're sent from the config file for \n's, etc */
 		int x, j;
-		newfestivalcommand = alloca(strlen(festivalcommand) + strlen(args.text) + 1);
+		newfestivalcommand = ast_alloca(strlen(festivalcommand) + strlen(args.text) + 1);
 
 		for (x = 0, j = 0; x < strlen(festivalcommand); x++) {
 			if (festivalcommand[x] == '\\' && festivalcommand[x + 1] == 'n') {

Modified: trunk/apps/app_getcpeid.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_getcpeid.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/apps/app_getcpeid.c (original)
+++ trunk/apps/app_getcpeid.c Tue Jul 31 15:21:43 2012
@@ -76,7 +76,7 @@
 	unsigned int x;
 
 	for (x = 0; x < 4; x++)
-		data[x] = alloca(80);
+		data[x] = ast_alloca(80);
 
 	strcpy(data[0], "** CPE Info **");
 	strcpy(data[1], "Identifying CPE...");

Modified: trunk/apps/app_macro.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_macro.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/apps/app_macro.c (original)
+++ trunk/apps/app_macro.c Tue Jul 31 15:21:43 2012
@@ -595,8 +595,7 @@
 	char *expr = NULL, *label_a = NULL, *label_b = NULL;
 	int res = 0;
 
-	if (!(expr = ast_strdupa(data)))
-		return -1;
+	expr = ast_strdupa(data);
 
 	if ((label_a = strchr(expr, '?'))) {
 		*label_a = '\0';

Modified: trunk/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_meetme.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/apps/app_meetme.c (original)
+++ trunk/apps/app_meetme.c Tue Jul 31 15:21:43 2012
@@ -4322,8 +4322,7 @@
 		return -1;
 	}
 	
-	if (!(localdata = ast_strdupa(data)))
-		return -1;
+	localdata = ast_strdupa(data);
 
 	AST_STANDARD_APP_ARGS(args, localdata);
 	

Modified: trunk/apps/app_minivm.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_minivm.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/apps/app_minivm.c (original)
+++ trunk/apps/app_minivm.c Tue Jul 31 15:21:43 2012
@@ -2054,10 +2054,6 @@
 		return -1;
 	}
 	tmpptr = ast_strdupa((char *)data);
-	if (!tmpptr) {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return -1;
-	}
 	argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv));
 	if (argc < 4) {
 		ast_log(LOG_ERROR, "%d arguments passed to MiniVM_MWI, need 4.\n", argc);
@@ -2102,10 +2098,6 @@
 		return -1;
 	}
 	tmpptr = ast_strdupa((char *)data);
-	if (!tmpptr) {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return -1;
-	}
 	argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv));
 
 	if (argc == 2 && !ast_strlen_zero(argv[1]))
@@ -2186,10 +2178,6 @@
 		return -1;
 	}
 	tmp = ast_strdupa((char *)data);
-	if (!tmp) {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return -1;
-	}
 	argc = ast_app_separate_args(tmp, ',', argv, ARRAY_LEN(argv));
 	if (argc == 2) {
 		if (ast_app_parse_options(minivm_app_options, &flags, opts, argv[1])) {
@@ -2249,10 +2237,6 @@
 		return -1;
 	}
 	tmpptr = ast_strdupa((char *)data);
-	if (!tmpptr) {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return -1;
-	}
 	argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv));
 
 	if (argc == 2) {
@@ -2474,14 +2458,9 @@
 	if (ast_strlen_zero(data))  {
 		ast_log(LOG_ERROR, "MinivmAccmess needs at least two arguments: account and option\n");
 		error = TRUE;
-	} else 
+	} else {
 		tmpptr = ast_strdupa((char *)data);
-	if (!error) {
-		if (!tmpptr) {
-			ast_log(LOG_ERROR, "Out of memory\n");
-			error = TRUE;
-		} else
-			argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv));
+		argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv));
 	}
 
 	if (argc <=1) {
@@ -2621,7 +2600,7 @@
 			char *varname = ast_strdupa(var->value);
 			struct ast_variable *tmpvar;
 
-			if (varname && (varval = strchr(varname, '='))) {
+			if ((varval = strchr(varname, '='))) {
 				*varval = '\0';
 				varval++;
 				if ((tmpvar = ast_variable_new(varname, varval, ""))) {
@@ -2679,11 +2658,6 @@
 		return 0;
 
 	msg_format = ast_strdupa(config);
-	if (msg_format == NULL) {
-		ast_log(LOG_WARNING, "Out of memory.\n");
-		ast_free(newzone);
-		return 0;
-	}
 
 	timezone_str = strsep(&msg_format, "|");
 	if (!msg_format) {
@@ -3199,10 +3173,7 @@
 	struct minivm_account *vmu;
 	char *username, *domain, *colname;
 
-	if (!(username = ast_strdupa(data))) {
-		ast_log(LOG_ERROR, "Memory Error!\n");
-		return -1;
-	}
+	username = ast_strdupa(data);
 
 	if ((colname = strchr(username, ':'))) {
 		*colname = '\0';
@@ -3352,10 +3323,8 @@
 
 	*buf = '\0';
 
-	if (!(username = ast_strdupa(data))) {	/* Copy indata to local buffer */
-		ast_log(LOG_WARNING, "Memory error!\n");
-		return -1;
-	}
+	username = ast_strdupa(data);
+
 	if ((countername = strchr(username, ':'))) {
 		*countername = '\0';
 		countername++;
@@ -3410,10 +3379,7 @@
 		return -1;
 	change = atoi(value);
 
-	if (!(username = ast_strdupa(data))) {	/* Copy indata to local buffer */
-		ast_log(LOG_WARNING, "Memory error!\n");
-		return -1;
-	}
+	username = ast_strdupa(data);
 
 	if ((countername = strchr(username, ':'))) {
 		*countername = '\0';

Modified: trunk/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_mixmonitor.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/apps/app_mixmonitor.c (original)
+++ trunk/apps/app_mixmonitor.c Tue Jul 31 15:21:43 2012
@@ -905,7 +905,7 @@
 		ast_log(LOG_WARNING, "No file name was provided for a file save option.\n");
 	} else if (filename[0] != '/') {
 		char *build;
-		build = alloca(strlen(ast_config_AST_MONITOR_DIR) + strlen(filename) + 3);
+		build = ast_alloca(strlen(ast_config_AST_MONITOR_DIR) + strlen(filename) + 3);
 		sprintf(build, "%s/%s", ast_config_AST_MONITOR_DIR, filename);
 		filename = build;
 	}

Modified: trunk/apps/app_osplookup.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_osplookup.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/apps/app_osplookup.c (original)
+++ trunk/apps/app_osplookup.c Tue Jul 31 15:21:43 2012
@@ -2270,10 +2270,7 @@
 		AST_APP_ARG(options);
 	);
 
-	if (!(tmp = ast_strdupa(data))) {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return OSP_AST_ERROR;
-	}
+	tmp = ast_strdupa(data);
 
 	AST_STANDARD_APP_ARGS(args, tmp);
 
@@ -2365,10 +2362,7 @@
 		return OSP_AST_ERROR;
 	}
 
-	if (!(tmp = ast_strdupa(data))) {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return OSP_AST_ERROR;
-	}
+	tmp = ast_strdupa(data);
 
 	AST_STANDARD_APP_ARGS(args, tmp);
 
@@ -2654,10 +2648,7 @@
 		return OSP_AST_ERROR;
 	}
 
-	if (!(tmp = ast_strdupa(data))) {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return OSP_AST_ERROR;
-	}
+	tmp = ast_strdupa(data);
 
 	AST_STANDARD_APP_ARGS(args, tmp);
 
@@ -2836,10 +2827,7 @@
 		AST_APP_ARG(options);
 	);
 
-	if (!(tmp = ast_strdupa(data))) {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return OSP_AST_ERROR;
-	}
+	tmp = ast_strdupa(data);
 
 	AST_STANDARD_APP_ARGS(args, tmp);
 

Modified: trunk/apps/app_sms.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_sms.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/apps/app_sms.c (original)
+++ trunk/apps/app_sms.c Tue Jul 31 15:21:43 2012
@@ -1604,7 +1604,7 @@
 		samples = MAXSAMPLES;
 	}
 	len = samples * sizeof(*buf) + AST_FRIENDLY_OFFSET;
-	buf = alloca(len);
+	buf = ast_alloca(len);
 
 	f.frametype = AST_FRAME_VOICE;
 	ast_format_set(&f.subclass.format, __OUT_FMT, 0);

Modified: trunk/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Tue Jul 31 15:21:43 2012
@@ -1096,7 +1096,7 @@
 
 static int inprocess_count(const char *context, const char *mailbox, int delta)
 {
-	struct inprocess *i, *arg = alloca(sizeof(*arg) + strlen(context) + strlen(mailbox) + 2);
+	struct inprocess *i, *arg = ast_alloca(sizeof(*arg) + strlen(context) + strlen(mailbox) + 2);
 	arg->context = arg->mailbox + strlen(mailbox) + 1;
 	strcpy(arg->mailbox, mailbox); /* SAFE */
 	strcpy(arg->context, context); /* SAFE */
@@ -1719,10 +1719,10 @@
 					}
 					value = strstr(tmp, ",");
 					if (!value) {
-						new = alloca(strlen(newpassword)+1);
+						new = ast_alloca(strlen(newpassword)+1);
 						sprintf(new, "%s", newpassword);
 					} else {
-						new = alloca((strlen(value) + strlen(newpassword) + 1));
+						new = ast_alloca((strlen(value) + strlen(newpassword) + 1));
 						sprintf(new, "%s%s", newpassword, value);
 					}
 					if (!(cat = ast_category_get(cfg, category))) {
@@ -1757,7 +1757,7 @@
 					} else {
 						var = NULL;
 					}
-					new = alloca(strlen(newpassword) + 1);
+					new = ast_alloca(strlen(newpassword) + 1);
 					sprintf(new, "%s", newpassword);
 					if (!(cat = ast_category_get(cfg, category))) {
 						ast_debug(4, "failed to get category!\n");
@@ -4472,7 +4472,7 @@
 	int txtsize = 0;
 
 	txtsize = (strlen(file) + 5)*sizeof(char);
-	txt = alloca(txtsize);
+	txt = ast_alloca(txtsize);
 	/* Sprintf here would safe because we alloca'd exactly the right length,
 	 * but trying to eliminate all sprintf's anyhow
 	 */
@@ -8782,7 +8782,7 @@
 	int cmd;
 	char *buf;
 
-	buf = alloca(strlen(box) + 2);
+	buf = ast_alloca(strlen(box) + 2);
 	strcpy(buf, box);
 	strcat(buf, "s");
 
@@ -11697,7 +11697,7 @@
 		read_password_from_file(secretfn, vmu->password, sizeof(vmu->password));
 	}
 
-	mailbox_full = alloca(strlen(box) + strlen(context) + 1);
+	mailbox_full = ast_alloca(strlen(box) + strlen(context) + 1);
 	strcpy(mailbox_full, box);
 	strcat(mailbox_full, "@");
 	strcat(mailbox_full, context);
@@ -15229,12 +15229,7 @@
 		goto vm_forward_cleanup;
 	}
 
-	if (!(msg_nums = alloca(sizeof(int) * num_msgs)))
-	{
-		ast_log(LOG_ERROR, "Unable to allocate stack space! Expect awful things!\n");
-		res = -1;
-		goto vm_forward_cleanup;
-	}
+	msg_nums = ast_alloca(sizeof(int) * num_msgs);
 
 	if ((res = message_range_and_existence_check(&from_vms, msg_ids, num_msgs, msg_nums, vmu) < 0)) {
 		goto vm_forward_cleanup;
@@ -15359,11 +15354,7 @@
 		goto vm_move_cleanup;
 	}
 
-	if (!(old_msg_nums = alloca(sizeof(int) * num_msgs))) {
-		ast_log(LOG_ERROR, "Unable to allocate stack space! Expect awful things!\n");
-		res = -1;
-		goto vm_move_cleanup;
-	}
+	old_msg_nums = ast_alloca(sizeof(int) * num_msgs);
 
 	if ((res = message_range_and_existence_check(&vms, old_msg_ids, num_msgs, old_msg_nums, vmu)) < 0) {
 		goto vm_move_cleanup;
@@ -15464,11 +15455,7 @@
 		goto vm_remove_cleanup;
 	}
 
-	if (!(msg_nums = alloca(sizeof(int) * num_msgs))) {
-		ast_log(LOG_ERROR, "Unable to allocate stack space! Expect awful things\n");
-		res = -1;
-		goto vm_remove_cleanup;
-	}
+	msg_nums = ast_alloca(sizeof(int) * num_msgs);
 
 	if ((res = message_range_and_existence_check(&vms, msgs, num_msgs, msg_nums, vmu)) < 0) {
 		goto vm_remove_cleanup;

Modified: trunk/apps/app_while.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_while.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/apps/app_while.c (original)
+++ trunk/apps/app_while.c Tue Jul 31 15:21:43 2012
@@ -236,7 +236,7 @@
 		condition = ast_strdupa(data);
 
 	size = strlen(ast_channel_context(chan)) + strlen(ast_channel_exten(chan)) + 32;
-	my_name = alloca(size);
+	my_name = ast_alloca(size);
 	memset(my_name, 0, size);
 	snprintf(my_name, size, "%s_%s_%d", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan));
 	
@@ -281,7 +281,7 @@
 	if (!end && !while_pri) {
 		char *goto_str;
 		size = strlen(ast_channel_context(chan)) + strlen(ast_channel_exten(chan)) + 32;
-		goto_str = alloca(size);
+		goto_str = ast_alloca(size);
 		memset(goto_str, 0, size);
 		snprintf(goto_str, size, "%s,%s,%d", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan));
 		pbx_builtin_setvar_helper(chan, varname, goto_str);
@@ -293,7 +293,7 @@
 		if (! pbx_builtin_getvar_helper(chan, end_varname)) {
 			char *goto_str;
 			size = strlen(ast_channel_context(chan)) + strlen(ast_channel_exten(chan)) + 32;
-			goto_str = alloca(size);
+			goto_str = ast_alloca(size);
 			memset(goto_str, 0, size);
 			snprintf(goto_str, size, "%s,%s,%d", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan)+1);
 			pbx_builtin_setvar_helper(chan, end_varname, goto_str);

Modified: trunk/cdr/cdr_pgsql.c
URL: http://svnview.digium.com/svn/asterisk/trunk/cdr/cdr_pgsql.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/cdr/cdr_pgsql.c (original)
+++ trunk/cdr/cdr_pgsql.c Tue Jul 31 15:21:43 2012
@@ -617,7 +617,7 @@
 			if (strchr(schemaname, '\\') || strchr(schemaname, '\'')) {
 				char *tmp = schemaname, *ptr;
 
-				ptr = schemaname = alloca(strlen(tmp) * 2 + 1);
+				ptr = schemaname = ast_alloca(strlen(tmp) * 2 + 1);
 				for (; *tmp; tmp++) {
 					if (strchr("\\'", *tmp)) {
 						*ptr++ = *tmp;
@@ -630,7 +630,7 @@
 			if (strchr(tablename, '\\') || strchr(tablename, '\'')) {
 				char *tmp = tablename, *ptr;
 
-				ptr = tablename = alloca(strlen(tmp) * 2 + 1);
+				ptr = tablename = ast_alloca(strlen(tmp) * 2 + 1);
 				for (; *tmp; tmp++) {
 					if (strchr("\\'", *tmp)) {
 						*ptr++ = *tmp;

Modified: trunk/channels/chan_alsa.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_alsa.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/channels/chan_alsa.c (original)
+++ trunk/channels/chan_alsa.c Tue Jul 31 15:21:43 2012
@@ -182,7 +182,7 @@
 		ast_debug(1, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
 	}
 
-	hwparams = alloca(snd_pcm_hw_params_sizeof());
+	hwparams = ast_alloca(snd_pcm_hw_params_sizeof());
 	memset(hwparams, 0, snd_pcm_hw_params_sizeof());
 	snd_pcm_hw_params_any(handle, hwparams);
 
@@ -223,7 +223,7 @@
 	if (err < 0)
 		ast_log(LOG_ERROR, "Couldn't set the new hw params: %s\n", snd_strerror(err));
 
-	swparams = alloca(snd_pcm_sw_params_sizeof());
+	swparams = ast_alloca(snd_pcm_sw_params_sizeof());
 	memset(swparams, 0, snd_pcm_sw_params_sizeof());
 	snd_pcm_sw_params_current(handle, swparams);
 

Modified: trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Tue Jul 31 15:21:43 2012
@@ -4181,7 +4181,7 @@
 
 	snprintf(cause_str, sizeof(cause_str), "R2 DISCONNECT (%s)", openr2_proto_get_disconnect_string(cause));
 	datalen += strlen(cause_str);
-	cause_code = alloca(datalen);
+	cause_code = ast_alloca(datalen);
 	cause_code->ast_cause = dahdi_r2_cause_to_ast_cause(cause);
 	ast_copy_string(cause_code->chan_name, ast_channel_name(p->owner), AST_CHANNEL_NAME);
 	ast_copy_string(cause_code->code, cause_str, datalen + 1 - sizeof(*cause_code));

Modified: trunk/channels/chan_gtalk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_gtalk.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/channels/chan_gtalk.c (original)
+++ trunk/channels/chan_gtalk.c Tue Jul 31 15:21:43 2012
@@ -1908,15 +1908,17 @@
 
 	if (data) {
 		s = ast_strdupa(data);
-		if (s) {
-			sender = strsep(&s, "/");
-			if (sender && (sender[0] != '\0')) {
-				to = strsep(&s, "/");
-			}
-			if (!to) {
-				ast_log(LOG_ERROR, "Bad arguments in Gtalk Dialstring: %s\n", data);
-				return NULL;
-			}
+		sender = strsep(&s, "/");
+		if (sender && (sender[0] != '\0')) {
+			to = strsep(&s, "/");
+		}
+		if (!to) {
+			ast_log(LOG_ERROR, "Bad arguments in Gtalk Dialstring: %s\n", data);
+			return NULL;
+		}
+		if (!to) {
+			ast_log(LOG_ERROR, "Bad arguments in Gtalk Dialstring: %s\n", (char*) data);
+			return NULL;
 		}
 	}
 

Modified: trunk/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Tue Jul 31 15:21:43 2012
@@ -3084,10 +3084,7 @@
 	unsigned char sum[16], buf[1024];
 	char *s2, *last;
 
-	if (!(s2 = alloca(strlen(s) + 100))) {
-		ast_log(LOG_WARNING, "Alloca failed!\n");
-		return -1;
-	}
+	s2 = ast_alloca(strlen(s) + 100);
 
 	last = strrchr(s, '/');
 	if (last)
@@ -6340,7 +6337,7 @@
 	int padding;
 	unsigned char *workspace;
 
-	workspace = alloca(*datalen);
+	workspace = ast_alloca(*datalen);
 	memset(f, 0, sizeof(*f));
 	if (ntohs(fh->scallno) & IAX_FLAG_FULL) {
 		struct ast_iax2_full_enc_hdr *efh = (struct ast_iax2_full_enc_hdr *)fh;
@@ -6386,9 +6383,7 @@
 {
 	int padding;
 	unsigned char *workspace;
-	workspace = alloca(*datalen + 32);
-	if (!workspace)
-		return -1;
+	workspace = ast_alloca(*datalen + 32);
 	if (ntohs(fh->scallno) & IAX_FLAG_FULL) {
 		struct ast_iax2_full_enc_hdr *efh = (struct ast_iax2_full_enc_hdr *)fh;
 		if (iaxdebug)
@@ -10016,9 +10011,9 @@
 	char *using_prefs = "mine";
 
 	/* allocate an iax_frame with 4096 bytes of data buffer */
-	fr = alloca(sizeof(*fr) + 4096);
+	fr = ast_alloca(sizeof(*fr) + 4096);
 	memset(fr, 0, sizeof(*fr));
-	fr->afdatalen = 4096; /* From alloca() above */
+	fr->afdatalen = 4096; /* From ast_alloca() above */
 
 	/* Copy frequently used parameters to the stack */
 	res = thread->buf_len;
@@ -10236,7 +10231,7 @@
 		/* add length of subclass */
 		data_size += strlen(subclass);
 
-		cause_code = alloca(data_size);
+		cause_code = ast_alloca(data_size);
 		ast_copy_string(cause_code->chan_name, ast_channel_name(iaxs[fr->callno]->owner), AST_CHANNEL_NAME);
 
 		cause_code->ast_cause = ies.causecode;
@@ -12470,9 +12465,7 @@
 	char *host;
 	char *portstr;
 
-	if (!(tmp = ast_strdupa(srcaddr)))
-		return -1;
-
+	tmp = ast_strdupa(srcaddr);
 	ast_sockaddr_split_hostport(tmp, &host, &portstr, 0);
 
 	if (portstr) {
@@ -12935,7 +12928,7 @@
 				ast_append_acl(v->name, v->value, &user->acl, NULL, &subscribe_acl_change);
 			} else if (!strcasecmp(v->name, "setvar")) {
 				varname = ast_strdupa(v->value);
-				if (varname && (varval = strchr(varname,'='))) {
+				if ((varval = strchr(varname, '='))) {
 					*varval = '\0';
 					varval++;
 					if((tmpvar = ast_variable_new(varname, varval, ""))) {

Modified: trunk/channels/chan_jingle.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_jingle.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/channels/chan_jingle.c (original)
+++ trunk/channels/chan_jingle.c Tue Jul 31 15:21:43 2012
@@ -1553,14 +1553,16 @@
 
 	if (data) {
 		s = ast_strdupa(data);
-		if (s) {
-			sender = strsep(&s, "/");
-			if (sender && (sender[0] != '\0'))
-				to = strsep(&s, "/");
-			if (!to) {
-				ast_log(LOG_ERROR, "Bad arguments in Jingle Dialstring: %s\n", data);
-				return NULL;
-			}
+		sender = strsep(&s, "/");
+		if (sender && (sender[0] != '\0'))
+			to = strsep(&s, "/");
+		if (!to) {
+			ast_log(LOG_ERROR, "Bad arguments in Jingle Dialstring: %s\n", data);
+			return NULL;
+		}
+		if (!to) {
+			ast_log(LOG_ERROR, "Bad arguments in Jingle Dialstring: %s\n", (char*) data);
+			return NULL;
 		}
 	}
 

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Jul 31 15:21:43 2012
@@ -5657,7 +5657,7 @@
 
 				/* Change the dialog callid. */
 				callid_size = strlen(tmpcall) + strlen(peer->fromdomain) + 2;
-				new_callid = alloca(callid_size);
+				new_callid = ast_alloca(callid_size);
 				snprintf(new_callid, callid_size, "%s@%s", tmpcall, peer->fromdomain);
 				change_callid_pvt(dialog, new_callid);
 			}
@@ -13829,7 +13829,7 @@
 					cid_num = S_COR(ast_channel_caller(caller)->id.number.valid,
 						ast_channel_caller(caller)->id.number.str, "");
 					need = strlen(cid_num) + strlen(p->fromdomain) + sizeof("sip:@");
-					remote_target = alloca(need);
+					remote_target = ast_alloca(need);
 					snprintf(remote_target, need, "sip:%s@%s", cid_num, p->fromdomain);
 
 					remote_display = ast_strdupa(S_COR(ast_channel_caller(caller)->id.name.valid,
@@ -13838,7 +13838,7 @@
 					connected_num = S_COR(ast_channel_connected(caller)->id.number.valid,
 						ast_channel_connected(caller)->id.number.str, "");
 					need = strlen(connected_num) + strlen(p->fromdomain) + sizeof("sip:@");
-					local_target = alloca(need);
+					local_target = ast_alloca(need);
 					snprintf(local_target, need, "sip:%s@%s", connected_num, p->fromdomain);
 
 					local_display = ast_strdupa(S_COR(ast_channel_connected(caller)->id.name.valid,
@@ -25025,7 +25025,8 @@
 			payload_size = ast_connected_line_build_data(connected_line_data,
 				sizeof(connected_line_data), &connected_to_target, NULL);
 			frame_size = payload_size + sizeof(*frame_payload);
-			if (payload_size != -1 && (frame_payload = alloca(frame_size))) {
+			if (payload_size != -1) {
+				frame_payload = ast_alloca(frame_size);
 				frame_payload->payload_size = payload_size;
 				memcpy(frame_payload->payload, connected_line_data, payload_size);
 				frame_payload->action = AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO;
@@ -27037,7 +27038,7 @@
 				int data_size = sizeof(*cause_code);
 				/* size of the string making up the cause code is "SIP " + cause length */
 				data_size += 4 + strlen(REQ_OFFSET_TO_STR(req, rlpart2));
-				cause_code = alloca(data_size);
+				cause_code = ast_alloca(data_size);
 
 				ast_copy_string(cause_code->chan_name, ast_channel_name(p->owner), AST_CHANNEL_NAME);
 
@@ -31734,7 +31735,7 @@
 	}
 	if (ok) {
 		size_t len = strlen(inbuf);
-		subbuf = alloca(len + 1);
+		subbuf = ast_alloca(len + 1);
 		ast_get_encoded_str(inbuf, subbuf, len + 1);
 		pbx_builtin_setvar_helper(chan, varbuf, subbuf);
 		if (sipdebug) {

Modified: trunk/channels/sig_analog.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_analog.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/channels/sig_analog.c (original)
+++ trunk/channels/sig_analog.c Tue Jul 31 15:21:43 2012
@@ -2734,7 +2734,7 @@
 		data_size += 7;
 		subclass = analog_event2str(res);
 		data_size += strlen(subclass);
-		cause_code = alloca(data_size);
+		cause_code = ast_alloca(data_size);
 		cause_code->ast_cause = AST_CAUSE_NORMAL_CLEARING;
 		ast_copy_string(cause_code->chan_name, ast_channel_name(ast), AST_CHANNEL_NAME);
 		snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "ANALOG %s", subclass);

Modified: trunk/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_pri.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/channels/sig_pri.c (original)
+++ trunk/channels/sig_pri.c Tue Jul 31 15:21:43 2012
@@ -1286,7 +1286,7 @@
 	chan = pri->pvts[chanpos]->owner;
 	if (chan) {
 		int datalen = sizeof(*cause_code) + strlen(cause);
-		cause_code = alloca(datalen);
+		cause_code = ast_alloca(datalen);
 		cause_code->ast_cause = ast_cause;
 		ast_copy_string(cause_code->chan_name, ast_channel_name(chan), AST_CHANNEL_NAME);
 		ast_copy_string(cause_code->code, cause, datalen + 1 - sizeof(*cause_code));

Modified: trunk/channels/sig_ss7.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_ss7.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/channels/sig_ss7.c (original)
+++ trunk/channels/sig_ss7.c Tue Jul 31 15:21:43 2012
@@ -389,7 +389,7 @@
 	struct ast_control_pvt_cause_code *cause_code;
 	int datalen = sizeof(*cause_code) + strlen(cause);
 
-	cause_code = alloca(datalen);
+	cause_code = ast_alloca(datalen);
 	cause_code->ast_cause = ast_cause;
 	ast_copy_string(cause_code->chan_name, ast_channel_name(owner), AST_CHANNEL_NAME);
 	ast_copy_string(cause_code->code, cause, datalen + 1 - sizeof(*cause_code));

Modified: trunk/funcs/func_channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_channel.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/funcs/func_channel.c (original)
+++ trunk/funcs/func_channel.c Tue Jul 31 15:21:43 2012
@@ -684,7 +684,7 @@
 			     char *data, struct ast_str **buf, ssize_t len)
 {
 	struct ast_channel *mchan = ast_channel_get_by_name(ast_channel_linkedid(chan));
-	char *template = alloca(4 + strlen(data));
+	char *template = ast_alloca(4 + strlen(data));
 	sprintf(template, "${%s}", data); /* SAFE */
 	ast_str_substitute_variables(buf, len, mchan ? mchan : chan, template);
 	if (mchan) {

Modified: trunk/funcs/func_cut.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_cut.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/funcs/func_cut.c (original)
+++ trunk/funcs/func_cut.c Tue Jul 31 15:21:43 2012
@@ -119,7 +119,7 @@
 			count++;
 	}
 
-	sortable_keys = alloca(count * sizeof(struct sortable_keys));
+	sortable_keys = ast_alloca(count * sizeof(struct sortable_keys));
 
 	memset(sortable_keys, 0, count * sizeof(struct sortable_keys));
 
@@ -170,9 +170,8 @@
 	/* Check arguments */
 	if (args.argc < 3) {
 		return ERROR_NOARG;
-	} else if (!(var_expr = alloca(strlen(args.varname) + 4))) {
-		return ERROR_NOMEM;
-	}
+	}
+	var_expr = ast_alloca(strlen(args.varname) + 4);
 
 	/* Get the value of the variable named in the 1st argument */
 	snprintf(var_expr, strlen(args.varname) + 4, "${%s}", args.varname);

Modified: trunk/funcs/func_global.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_global.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/funcs/func_global.c (original)
+++ trunk/funcs/func_global.c Tue Jul 31 15:21:43 2012
@@ -148,7 +148,7 @@
 	AST_STANDARD_APP_ARGS(args, data);
 
 	if (!ast_strlen_zero(args.chan)) {
-		char *prefix = alloca(strlen(args.chan) + 2);
+		char *prefix = ast_alloca(strlen(args.chan) + 2);
 		sprintf(prefix, "%s-", args.chan);
 		if (!(c_ref = ast_channel_get_by_name(args.chan)) && !(c_ref = ast_channel_get_by_name_prefix(prefix, strlen(prefix)))) {
 			ast_log(LOG_ERROR, "Channel '%s' not found!  Variable '%s' will be blank.\n", args.chan, args.var);
@@ -206,7 +206,7 @@
 	AST_STANDARD_APP_ARGS(args, data);
 
 	if (!ast_strlen_zero(args.chan)) {
-		char *prefix = alloca(strlen(args.chan) + 2);
+		char *prefix = ast_alloca(strlen(args.chan) + 2);
 		sprintf(prefix, "%s-", args.chan);
 		if (!(c_ref = ast_channel_get_by_name(args.chan)) && !(c_ref = ast_channel_get_by_name_prefix(prefix, strlen(prefix)))) {
 			ast_log(LOG_ERROR, "Channel '%s' not found!  Variable '%s' not set to '%s'.\n", args.chan, args.var, value);

Modified: trunk/funcs/func_logic.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_logic.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/funcs/func_logic.c (original)
+++ trunk/funcs/func_logic.c Tue Jul 31 15:21:43 2012
@@ -250,17 +250,15 @@
 		struct ast_channel *chan2;
 
 		if ((chan2 = ast_channel_get_by_name(args.channel))) {
-			char *s = alloca(strlen(args.varname) + 4);
-			if (s) {
-				sprintf(s, "${%s}", args.varname);
-				ast_channel_lock(chan2);
-				if (buf) {
-					pbx_substitute_variables_helper(chan2, s, buf, len);
-				} else {
-					ast_str_substitute_variables(str, len, chan2, s);
-				}
-				ast_channel_unlock(chan2);
+			char *s = ast_alloca(strlen(args.varname) + 4);
+			sprintf(s, "${%s}", args.varname);
+			ast_channel_lock(chan2);
+			if (buf) {
+				pbx_substitute_variables_helper(chan2, s, buf, len);
+			} else {
+				ast_str_substitute_variables(str, len, chan2, s);
 			}
+			ast_channel_unlock(chan2);
 			chan2 = ast_channel_unref(chan2);
 		}
 	}

Modified: trunk/funcs/func_strings.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_strings.c?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/funcs/func_strings.c (original)
+++ trunk/funcs/func_strings.c Tue Jul 31 15:21:43 2012
@@ -456,7 +456,7 @@
 	if (args.delim) {
 		ast_get_encoded_char(args.delim, delim, &delim_used);
 
-		varsubst = alloca(strlen(args.varname) + 4);
+		varsubst = ast_alloca(strlen(args.varname) + 4);
 
 		sprintf(varsubst, "${%s}", args.varname);
 		ast_str_substitute_variables(&str, 0, chan, varsubst);
@@ -522,7 +522,7 @@
 		ast_log(LOG_ERROR, "Usage: FIELDNUM(<listname>,<delimiter>,<fieldvalue>)\n");
 		res = -1;
 	} else {
-		varsubst = alloca(strlen(args.varname) + 4);
+		varsubst = ast_alloca(strlen(args.varname) + 4);
 		sprintf(varsubst, "${%s}", args.varname);
 
 		ast_str_substitute_variables(&str, 0, chan, varsubst);
@@ -606,7 +606,7 @@
 		return -1;
 	}
 
-	varsubst = alloca(strlen(args.listname) + 4);
+	varsubst = ast_alloca(strlen(args.listname) + 4);
 	sprintf(varsubst, "${%s}", args.listname);
 
 	/* If we don't lock the channel, the variable could disappear out from underneath us. */
@@ -636,7 +636,7 @@
 	}
 
 	dlen = strlen(args.delimiter);
-	delim = alloca(dlen + 1);
+	delim = ast_alloca(dlen + 1);
 	ast_get_encoded_str(args.delimiter, delim, dlen + 1);
 
 	if ((dlen = strlen(delim)) == 0) {
@@ -819,7 +819,7 @@
 		return -1;
 	}
 
-	varsubst = alloca(strlen(args.varname) + 4);
+	varsubst = ast_alloca(strlen(args.varname) + 4);
 	sprintf(varsubst, "${%s}", args.varname);
 	ast_str_substitute_variables(&str, 0, chan, varsubst);
 
@@ -906,7 +906,7 @@
 	find_size = strlen(args.find_string);
 
 	/* set varsubstr to the matching variable */
-	varsubstr = alloca(strlen(args.varname) + 4);
+	varsubstr = ast_alloca(strlen(args.varname) + 4);
 	sprintf(varsubstr, "${%s}", args.varname);
 	ast_str_substitute_variables(&str, 0, chan, varsubstr);
 
@@ -1026,9 +1026,10 @@
 	char *origvar = "", *value2, varname[256];
 	int i, ishash = 0;
 
+	if (!var) {
+		return -1;
+	}
 	value2 = ast_strdupa(value);
-	if (!var || !value2)
-		return -1;
 
 	if (!strcmp(cmd, "HASH")) {
 		const char *var2 = pbx_builtin_getvar_helper(chan, "~ODBCFIELDS~");
@@ -1544,7 +1545,7 @@
 		return -1;
 	}
 
-	varsubst = alloca(strlen(args.var) + 4);
+	varsubst = ast_alloca(strlen(args.var) + 4);
 	sprintf(varsubst, "${%s}", args.var);
 	ast_str_substitute_variables(&before, 0, chan, varsubst);
 
@@ -1608,7 +1609,7 @@
 		ast_get_encoded_char(args.delimiter, delimiter, &unused);
 	}
 
-	varsubst = alloca(strlen(args.var) + 4);
+	varsubst = ast_alloca(strlen(args.var) + 4);
 	sprintf(varsubst, "${%s}", args.var);
 	ast_str_substitute_variables(&previous_value, 0, chan, varsubst);
 

Modified: trunk/include/asterisk/strings.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/strings.h?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/include/asterisk/strings.h (original)
+++ trunk/include/asterisk/strings.h Tue Jul 31 15:21:43 2012
@@ -372,7 +372,7 @@
 /*! \brief The descriptor of a dynamic string
  *  XXX storage will be optimized later if needed
  * We use the ts field to indicate the type of storage.
- * Three special constants indicate malloc, alloca() or static
+ * Three special constants indicate malloc, ast_alloca() or static
  * variables, all other values indicate a
  * struct ast_threadstorage pointer.
  */
@@ -623,7 +623,7 @@
 #define ast_str_alloca(init_len)			\
 	({						\
 		struct ast_str *__ast_str_buf;			\
-		__ast_str_buf = alloca(sizeof(*__ast_str_buf) + init_len);	\
+		__ast_str_buf = ast_alloca(sizeof(*__ast_str_buf) + init_len);	\
 		__ast_str_buf->__AST_STR_LEN = init_len;			\
 		__ast_str_buf->__AST_STR_USED = 0;				\
 		__ast_str_buf->__AST_STR_TS = DS_ALLOCA;			\

Modified: trunk/include/asterisk/utils.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/utils.h?view=diff&rev=370655&r1=370654&r2=370655
==============================================================================
--- trunk/include/asterisk/utils.h (original)
+++ trunk/include/asterisk/utils.h Tue Jul 31 15:21:43 2012
@@ -645,6 +645,15 @@
 )
 
 #endif /* AST_DEBUG_MALLOC */
+
+/*!
+  \brief call __builtin_alloca to ensure we get gcc builtin semantics
+  \param size The size of the buffer we want allocated
+

[... 1207 lines stripped ...]



More information about the asterisk-commits mailing list