diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-01-04 06:16:04 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-01-04 06:16:04 +0000 |
commit | 687ee51a2048934bbf04ac6abaa268153b5edfce (patch) | |
tree | f44ac123dc6b08edfc59490ff6e1d0cb145a6088 /include | |
parent | d0b9843936e6443422df6c56272771c14925e4e8 (diff) |
Allow early exit from traverse (bug #3221)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4655 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rwxr-xr-x | include/asterisk/astobj.h | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/include/asterisk/astobj.h b/include/asterisk/astobj.h index f6e5f7060..0f26b2f81 100755 --- a/include/asterisk/astobj.h +++ b/include/asterisk/astobj.h @@ -148,13 +148,13 @@ extern "C" { ast_mutex_destroy(&(container)->_lock); \ } while(0) -#define ASTOBJ_CONTAINER_TRAVERSE(container,eval) \ +#define ASTOBJ_CONTAINER_TRAVERSE(container,continue,eval) \ do { \ typeof((container)->head) iterator; \ typeof((container)->head) next; \ ASTOBJ_CONTAINER_RDLOCK(container); \ next = (container)->head; \ - while((iterator = next)) { \ + while((continue) && (iterator = next)) { \ next = iterator->next[0]; \ eval; \ } \ @@ -164,14 +164,12 @@ extern "C" { #define ASTOBJ_CONTAINER_FIND_FULL(container,data,field,hashfunc,hashoffset,comparefunc) \ ({ \ typeof((container)->head) found = NULL; \ - ASTOBJ_CONTAINER_TRAVERSE(container, do { \ + ASTOBJ_CONTAINER_TRAVERSE(container, !found, do { \ ASTOBJ_RDLOCK(iterator); \ if (!(comparefunc(iterator->field, (data)))) { \ found = ASTOBJ_REF(iterator); \ } \ ASTOBJ_UNLOCK(iterator); \ - if (found) \ - break; \ } while (0)); \ found; \ }) @@ -192,7 +190,7 @@ extern "C" { ({ \ typeof((container)->head) found = NULL; \ typeof((container)->head) prev = NULL; \ - ASTOBJ_CONTAINER_TRAVERSE(container, do { \ + ASTOBJ_CONTAINER_TRAVERSE(container, !found, do { \ ASTOBJ_RDLOCK(iterator); \ if (!(comparefunc(iterator->field, (data)))) { \ found = iterator; \ @@ -204,8 +202,6 @@ extern "C" { ASTOBJ_CONTAINER_UNLOCK(container); \ } \ ASTOBJ_UNLOCK(iterator); \ - if (found) \ - break; \ prev = iterator; \ } while (0)); \ found; \ @@ -214,7 +210,7 @@ extern "C" { #define ASTOBJ_CONTAINER_PRUNE_MARKED(container,destructor) \ do { \ typeof((container)->head) prev = NULL; \ - ASTOBJ_CONTAINER_TRAVERSE(container, do { \ + ASTOBJ_CONTAINER_TRAVERSE(container, 1, do { \ ASTOBJ_RDLOCK(iterator); \ if (iterator->objflags & ASTOBJ_FLAG_MARKED) { \ ASTOBJ_CONTAINER_WRLOCK(container); \ @@ -266,16 +262,16 @@ extern "C" { ASTOBJ_CONTAINER_LINK_FULL(container,newobj,(newobj)->name,name,ASTOBJ_DEFAULT_HASH,0,strcasecmp) #define ASTOBJ_CONTAINER_MARKALL(container) \ - ASTOBJ_CONTAINER_TRAVERSE(container,ASTOBJ_MARK(iterator)) + ASTOBJ_CONTAINER_TRAVERSE(container, 1, ASTOBJ_MARK(iterator)) #define ASTOBJ_CONTAINER_UNMARKALL(container) \ - ASTOBJ_CONTAINER_TRAVERSE(container,ASTOBJ_UNMARK(iterator)) + ASTOBJ_CONTAINER_TRAVERSE(container, 1, ASTOBJ_UNMARK(iterator)) #define ASTOBJ_DUMP(s,slen,obj) \ snprintf((s),(slen),"name: %s\nobjflags: %d\nrefcount: %d\n\n", (obj)->name, (obj)->objflags, (obj)->refcount); #define ASTOBJ_CONTAINER_DUMP(fd,s,slen,container) \ - ASTOBJ_CONTAINER_TRAVERSE(container,do { ASTOBJ_DUMP(s,slen,iterator); ast_cli(fd, s); } while(0)) + ASTOBJ_CONTAINER_TRAVERSE(container, 1, do { ASTOBJ_DUMP(s,slen,iterator); ast_cli(fd, s); } while(0)) #if defined(__cplusplus) || defined(c_plusplus) } |