From: Russell Bryant Date: Tue, 27 Dec 2005 20:03:07 +0000 (+0000) Subject: minor cleanups for another cli completion function ... X-Git-Tag: 1.4.0-beta1~3119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04fc58d0384b418468c71d3b268b5959d920f20b;p=thirdparty%2Fasterisk.git minor cleanups for another cli completion function ... git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7661 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/pbx.c b/pbx.c index 20754475fb..57f8c6e1d5 100644 --- a/pbx.c +++ b/pbx.c @@ -1196,10 +1196,9 @@ static int handle_show_function(int fd, int argc, char *argv[]) static char *complete_show_function(char *line, char *word, int pos, int state) { struct ast_custom_function *acf; + char *ret = NULL; int which = 0; - int wordlen; - - wordlen = strlen(word); + int wordlen = strlen(word); /* try to lock functions list ... */ if (ast_mutex_lock(&acflock)) { @@ -1210,15 +1209,15 @@ static char *complete_show_function(char *line, char *word, int pos, int state) for (acf = acf_root; acf; acf = acf->next) { if (!strncasecmp(word, acf->name, wordlen)) { if (++which > state) { - char *ret = strdup(acf->name); - ast_mutex_unlock(&acflock); - return ret; + ret = strdup(acf->name); + break; } } } ast_mutex_unlock(&acflock); - return NULL; + + return ret; } struct ast_custom_function* ast_custom_function_find(const char *name)