[asterisk-commits] rmudgett: trunk r365766 - /trunk/apps/app_followme.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 8 17:25:48 CDT 2012


Author: rmudgett
Date: Tue May  8 17:25:42 2012
New Revision: 365766

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=365766
Log:
Make FollowMe findmeexec() put the list head on the stack instead of mallocing it.

Why this tiny struct was malloced instead of the 28k struct in the last
change is beyond me.  Just doing my part to help stamp out sillyness.

Modified:
    trunk/apps/app_followme.c

Modified: trunk/apps/app_followme.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_followme.c?view=diff&rev=365766&r1=365765&r2=365766
==============================================================================
--- trunk/apps/app_followme.c (original)
+++ trunk/apps/app_followme.c Tue May  8 17:25:42 2012
@@ -906,14 +906,7 @@
 	char *rest, *number;
 	struct findme_user *tmpuser;
 	struct findme_user *fmuser;
-	struct findme_user_listptr *findme_user_list;
-
-	findme_user_list = ast_calloc(1, sizeof(*findme_user_list));
-	if (!findme_user_list) {
-		ast_log(LOG_WARNING, "Failed to allocate memory for findme_user_list\n");
-		return NULL;
-	}
-	AST_LIST_HEAD_INIT_NOLOCK(findme_user_list);
+	struct findme_user_listptr findme_user_list = AST_LIST_HEAD_NOLOCK_INIT_VALUE;
 
 	for (idx = 1; !ast_check_hangup(caller); ++idx) {
 		/* Find next followme numbers to dial. */
@@ -969,7 +962,7 @@
 					tmpuser->state = 0;
 					tmpuser->cleared = 0;
 					ast_copy_string(tmpuser->dialarg, dialarg, sizeof(dialarg));
-					AST_LIST_INSERT_TAIL(findme_user_list, tmpuser, entry);
+					AST_LIST_INSERT_TAIL(&findme_user_list, tmpuser, entry);
 				} else {
 					ast_verb(3, "couldn't reach at this number.\n");
 					ast_channel_lock(outbound);
@@ -1002,17 +995,17 @@
 			}
 		}
 
-		if (AST_LIST_EMPTY(findme_user_list)) {
+		if (AST_LIST_EMPTY(&findme_user_list)) {
 			continue;
 		}
 
-		winner = wait_for_winner(findme_user_list, nm, caller, tpargs->namerecloc, tpargs);
+		winner = wait_for_winner(&findme_user_list, nm, caller, tpargs->namerecloc, tpargs);
 		if (!winner) {
 			continue;
 		}
 
 		/* Destroy losing calls up to the winner.  The rest will be destroyed later. */
-		while ((fmuser = AST_LIST_REMOVE_HEAD(findme_user_list, entry))) {
+		while ((fmuser = AST_LIST_REMOVE_HEAD(&findme_user_list, entry))) {
 			if (fmuser->ochan == winner) {
 				/* Pass any connected line info up. */
 				tpargs->connected_out = fmuser->connected;
@@ -1030,7 +1023,7 @@
 		}
 		break;
 	}
-	destroy_calling_tree(findme_user_list);
+	destroy_calling_tree(&findme_user_list);
 	return winner;
 }
 




More information about the asterisk-commits mailing list