Mercurial > nomad > old-fuse
changeset 134:b1c7d4b13ce2
common: introduce list_for_each and avl_for_each
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sun, 18 Oct 2015 10:26:30 -0400 |
parents | ad398971b27a |
children | 2b39a5cf338b |
files | src/common/CMakeLists.txt src/common/include/nomad/iter.h |
diffstat | 2 files changed, 33 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/common/CMakeLists.txt Sun Oct 18 10:26:07 2015 -0400 +++ b/src/common/CMakeLists.txt Sun Oct 18 10:26:30 2015 -0400 @@ -49,6 +49,7 @@ include/nomad/attr.h include/nomad/config.h include/nomad/error.h + include/nomad/iter.h include/nomad/malloc.h include/nomad/mutex.h include/nomad/rand.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/common/include/nomad/iter.h Sun Oct 18 10:26:30 2015 -0400 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014-2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef __NOMAD_ITER_H +#define __NOMAD_ITER_H + +#define list_for_each(list, pos) \ + for (pos = list_head(list); pos; pos = list_next((list), pos)) + +#define avl_for_each(tree, pos) \ + for (pos = avl_first(tree); pos; pos = AVL_NEXT(tree, pos)) + +#endif