diff options
author | Russell Bryant <russell@russellbryant.com> | 2005-12-27 19:48:44 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2005-12-27 19:48:44 +0000 |
commit | 37e21fc61cb0f2147c79d497a866cb55dca6cfad (patch) | |
tree | 7d8e6d48921fcd3a4b2661bbfd84239dc9e14318 /channels/iax2-provision.c | |
parent | a19361c684fbf8aa5e580ffa6131c295e31e9c3c (diff) |
avoid unneeded calls to strlen in iax2 completion functions
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7659 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/iax2-provision.c')
-rw-r--r-- | channels/iax2-provision.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/channels/iax2-provision.c b/channels/iax2-provision.c index c1b6f4b3d..420e79213 100644 --- a/channels/iax2-provision.c +++ b/channels/iax2-provision.c @@ -156,21 +156,20 @@ char *iax_prov_complete_template(char *line, char *word, int pos, int state) { struct iax_template *c; int which=0; - char *ret; + char *ret = NULL; + int wordlen = strlen(word); + ast_mutex_lock(&provlock); - c = templates; - while(c) { - if (!strncasecmp(word, c->name, strlen(word))) { - if (++which > state) + for (c = templates; c; c = c->next) { + if (!strncasecmp(word, c->name, wordlen)) { + if (++which > state) { + ret = strdup(c->name); break; + } } - c = c->next; } - if (c) { - ret = strdup(c->name); - } else - ret = NULL; ast_mutex_unlock(&provlock); + return ret; } |