aboutsummaryrefslogtreecommitdiffstats
path: root/channels/iax2-provision.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-12-27 19:48:44 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-12-27 19:48:44 +0000
commit07d8efab6e28543087233f8a1c62862e0ebefa82 (patch)
tree7d8e6d48921fcd3a4b2661bbfd84239dc9e14318 /channels/iax2-provision.c
parent06ecd182a74b0db8ef9f1c46a0fc0569c3880715 (diff)
avoid unneeded calls to strlen in iax2 completion functions
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7659 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/iax2-provision.c')
-rw-r--r--channels/iax2-provision.c19
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;
}