[asterisk-commits] russell: branch russell/ast_channel_ao2 r183812 - /team/russell/ast_channel_a...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Mar 23 15:38:06 CDT 2009
Author: russell
Date: Mon Mar 23 15:38:03 2009
New Revision: 183812
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=183812
Log:
Use a name based iterator instead of doing the name checking manually
Modified:
team/russell/ast_channel_ao2/main/cli.c
Modified: team/russell/ast_channel_ao2/main/cli.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/main/cli.c?view=diff&rev=183812&r1=183811&r2=183812
==============================================================================
--- team/russell/ast_channel_ao2/main/cli.c (original)
+++ team/russell/ast_channel_ao2/main/cli.c Mon Mar 23 15:38:03 2009
@@ -1437,7 +1437,6 @@
{
struct ast_channel *c = NULL;
int which = 0;
- int wordlen;
char notfound = '\0';
char *ret = ¬found; /* so NULL can break the loop */
struct ast_channel_iterator *iter;
@@ -1446,18 +1445,16 @@
return NULL;
}
- if (!(iter = ast_channel_iterator_all_new(0))) {
- return NULL;
- }
-
- wordlen = strlen(word);
+ if (!(iter = ast_channel_iterator_by_name_new(0, word, strlen(word)))) {
+ return NULL;
+ }
while (ret == ¬found && (c = ast_channel_iterator_next(iter))) {
- ast_channel_lock(c);
- if (!strncasecmp(word, c->name, wordlen) && ++which > state) {
+ if (++which > state) {
+ ast_channel_lock(c);
ret = ast_strdup(c->name);
- }
- ast_channel_unlock(c);
+ ast_channel_unlock(c);
+ }
ast_channel_unref(c);
}
More information about the asterisk-commits
mailing list