]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
avoid multiple strlen calls in complete_queue
authorRussell Bryant <russell@russellbryant.com>
Thu, 29 Dec 2005 08:15:48 +0000 (08:15 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 29 Dec 2005 08:15:48 +0000 (08:15 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7667 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_queue.c

index c1054de0429a3438cc8aa6b2719f115aa141cd92..17bc06a263fe91e1109929f98681c73a1d14466e 100644 (file)
@@ -3360,17 +3360,22 @@ static int queue_show(int fd, int argc, char **argv)
 static char *complete_queue(char *line, char *word, int pos, int state)
 {
        struct ast_call_queue *q;
-       int which=0;
+       char *ret = NULL;
+       int which = 0;
+       int wordlen = strlen(word);
        
        ast_mutex_lock(&qlock);
        for (q = queues; q; q = q->next) {
-               if (!strncasecmp(word, q->name, strlen(word))) {
-                       if (++which > state)
+               if (!strncasecmp(word, q->name, wordlen)) {
+                       if (++which > state) {
+                               ret = strdup(q->name);  
                                break;
+                       }
                }
        }
        ast_mutex_unlock(&qlock);
-       return q ? strdup(q->name) : NULL;
+
+       return ret;
 }
 
 /*!\brief callback to display queues status in manager