X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fhindex.h;h=fb6b6d2bda0536e90efa632b9e0332a54ba2f4a0;hb=003ce655b7116d18c86a74c50391e54990346931;hp=10bf0244d76b14e946847cf6fc532814cf16ba5c;hpb=822b7f52108e1936f68fe2f726d0796df1b19903;p=sliver-openvswitch.git diff --git a/lib/hindex.h b/lib/hindex.h index 10bf0244d..fb6b6d2bd 100644 --- a/lib/hindex.h +++ b/lib/hindex.h @@ -129,7 +129,7 @@ void hindex_remove(struct hindex *, struct hindex_node *); */ #define HINDEX_FOR_EACH_WITH_HASH(NODE, MEMBER, HASH, HINDEX) \ for (ASSIGN_CONTAINER(NODE, hindex_node_with_hash(HINDEX, HASH), MEMBER); \ - &(NODE)->MEMBER != NULL; \ + NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER); \ ASSIGN_CONTAINER(NODE, (NODE)->MEMBER.s, MEMBER)) struct hindex_node *hindex_node_with_hash(const struct hindex *, size_t hash); @@ -139,15 +139,15 @@ struct hindex_node *hindex_node_with_hash(const struct hindex *, size_t hash); /* Iterates through every node in HINDEX. */ #define HINDEX_FOR_EACH(NODE, MEMBER, HINDEX) \ for (ASSIGN_CONTAINER(NODE, hindex_first(HINDEX), MEMBER); \ - &(NODE)->MEMBER != NULL; \ + NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER); \ ASSIGN_CONTAINER(NODE, hindex_next(HINDEX, &(NODE)->MEMBER), MEMBER)) /* Safe when NODE may be freed (not needed when NODE may be removed from the * hash index but its members remain accessible and intact). */ #define HINDEX_FOR_EACH_SAFE(NODE, NEXT, MEMBER, HINDEX) \ for (ASSIGN_CONTAINER(NODE, hindex_first(HINDEX), MEMBER); \ - (&(NODE)->MEMBER != NULL \ - ? ASSIGN_CONTAINER(NEXT, hindex_next(HINDEX, &(NODE)->MEMBER), MEMBER) \ + (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER) \ + ? ASSIGN_CONTAINER(NEXT, hindex_next(HINDEX, &(NODE)->MEMBER), MEMBER), 1 \ : 0); \ (NODE) = (NEXT))