[asterisk-commits] trunk - r7668 /trunk/apps/app_voicemail.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Dec 29 02:25:08 CST 2005


Author: russell
Date: Thu Dec 29 02:25:06 2005
New Revision: 7668

URL: http://svn.digium.com/view/asterisk?rev=7668&view=rev
Log:
normalize a loop and avoid multiple strlen calls when completing voicemail users

Modified:
    trunk/apps/app_voicemail.c

Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?rev=7668&r1=7667&r2=7668&view=diff
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Thu Dec 29 02:25:06 2005
@@ -5741,7 +5741,8 @@
 static char *complete_show_voicemail_users(char *line, char *word, int pos, int state)
 {
 	int which = 0;
-	struct ast_vm_user *vmu = users;
+	int wordlen;
+	struct ast_vm_user *vmu;
 	char *context = "";
 
 	/* 0 - show; 1 - voicemail; 2 - users; 3 - for; 4 - <context> */
@@ -5753,8 +5754,9 @@
 		else
 			return NULL;
 	}
-	while (vmu) {
-		if (!strncasecmp(word, vmu->context, strlen(word))) {
+	wordlen = strlen(word);
+	for (vmu = users; vmu; vmu = vmu->next) {
+		if (!strncasecmp(word, vmu->context, wordlen)) {
 			if (context && strcmp(context, vmu->context)) {
 				if (++which > state) {
 					return strdup(vmu->context);
@@ -5762,7 +5764,6 @@
 				context = vmu->context;
 			}
 		}
-		vmu = vmu->next;
 	}
 	return NULL;
 }



More information about the asterisk-commits mailing list