diff options
author | Russell Bryant <russell@russellbryant.com> | 2005-12-29 08:25:06 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2005-12-29 08:25:06 +0000 |
commit | 5c181546172e13d4e4ff9a694b1585469096294d (patch) | |
tree | 8a4aaaabf50745f691b6b075e35da8f0b219efd9 /apps/app_voicemail.c | |
parent | 1bd94abf57394057f7bbc97625b03cdc77ba4d71 (diff) |
normalize a loop and avoid multiple strlen calls when completing voicemail users
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7668 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r-- | apps/app_voicemail.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 9616afceb..6aa7bb5e3 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -5741,7 +5741,8 @@ static int handle_show_voicemail_zones(int fd, int argc, char *argv[]) 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 @@ static char *complete_show_voicemail_users(char *line, char *word, int pos, int 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 @@ static char *complete_show_voicemail_users(char *line, char *word, int pos, int context = vmu->context; } } - vmu = vmu->next; } return NULL; } |