projects
/
openvswitch
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
cd10ed7
)
hmap: New macro HMAP_FOR_EACH_CONTINUE.
author
Ben Pfaff
<blp@nicira.com>
Thu, 28 Oct 2010 23:17:29 +0000
(16:17 -0700)
committer
Ben Pfaff
<blp@nicira.com>
Fri, 12 Nov 2010 22:50:45 +0000
(14:50 -0800)
lib/hmap.h
patch
|
blob
|
history
diff --git
a/lib/hmap.h
b/lib/hmap.h
index 3929c9ce57a5750d41e215515854dfddd32c1bd8..674c6c778d2060a835fa98dc47c35db9fca725b3 100644
(file)
--- a/
lib/hmap.h
+++ b/
lib/hmap.h
@@
-133,17
+133,17
@@
static inline struct hmap_node *hmap_first_in_bucket(const struct hmap *,
size_t hash);
static inline struct hmap_node *hmap_next_in_bucket(const struct hmap_node *);
size_t hash);
static inline struct hmap_node *hmap_next_in_bucket(const struct hmap_node *);
-/* Iteration.
- *
- * The _SAFE version is needed when NODE may be freed. It is not needed when
- * NODE may be removed from the hash map but its members remain accessible and
- * intact. */
+/* Iteration. */
+
+/* Iterates through every node in HMAP. */
#define HMAP_FOR_EACH(NODE, MEMBER, HMAP) \
for ((NODE) = OBJECT_CONTAINING(hmap_first(HMAP), NODE, MEMBER); \
&(NODE)->MEMBER != NULL; \
(NODE) = OBJECT_CONTAINING(hmap_next(HMAP, &(NODE)->MEMBER), \
NODE, MEMBER))
#define HMAP_FOR_EACH(NODE, MEMBER, HMAP) \
for ((NODE) = OBJECT_CONTAINING(hmap_first(HMAP), NODE, MEMBER); \
&(NODE)->MEMBER != NULL; \
(NODE) = OBJECT_CONTAINING(hmap_next(HMAP, &(NODE)->MEMBER), \
NODE, MEMBER))
+/* Safe when NODE may be freed (not needed when NODE may be removed from the
+ * hash map but its members remain accessible and intact). */
#define HMAP_FOR_EACH_SAFE(NODE, NEXT, MEMBER, HMAP) \
for ((NODE) = OBJECT_CONTAINING(hmap_first(HMAP), NODE, MEMBER); \
(&(NODE)->MEMBER != NULL \
#define HMAP_FOR_EACH_SAFE(NODE, NEXT, MEMBER, HMAP) \
for ((NODE) = OBJECT_CONTAINING(hmap_first(HMAP), NODE, MEMBER); \
(&(NODE)->MEMBER != NULL \
@@
-152,6
+152,14
@@
static inline struct hmap_node *hmap_next_in_bucket(const struct hmap_node *);
: 0); \
(NODE) = (NEXT))
: 0); \
(NODE) = (NEXT))
+/* Continues an iteration from just after NODE. */
+#define HMAP_FOR_EACH_CONTINUE(NODE, MEMBER, HMAP) \
+ for ((NODE) = OBJECT_CONTAINING(hmap_next(HMAP, &(NODE)->MEMBER), \
+ NODE, MEMBER); \
+ &(NODE)->MEMBER != NULL; \
+ (NODE) = OBJECT_CONTAINING(hmap_next(HMAP, &(NODE)->MEMBER), \
+ NODE, MEMBER))
+
static inline struct hmap_node *hmap_first(const struct hmap *);
static inline struct hmap_node *hmap_next(const struct hmap *,
const struct hmap_node *);
static inline struct hmap_node *hmap_first(const struct hmap *);
static inline struct hmap_node *hmap_next(const struct hmap *,
const struct hmap_node *);