X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fhmap.c;h=97c6959de014497474e2fec3459ba421c4ed7567;hb=620606f63cc56c7541005dc6787106789e2c364e;hp=9f2774465c3c357b81b4a0086594966e1a72cd11;hpb=ee114c23f735a91b165dab0908c1fdea736e782a;p=sliver-openvswitch.git diff --git a/lib/hmap.c b/lib/hmap.c index 9f2774465..97c6959de 100644 --- a/lib/hmap.c +++ b/lib/hmap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010 Nicira Networks. + * Copyright (c) 2008, 2009, 2010, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ #include #include "hmap.h" -#include #include #include #include "coverage.h" @@ -91,8 +90,8 @@ resize(struct hmap *hmap, size_t new_mask) struct hmap tmp; size_t i; - assert(!(new_mask & (new_mask + 1))); - assert(new_mask != SIZE_MAX); + ovs_assert(!(new_mask & (new_mask + 1))); + ovs_assert(new_mask != SIZE_MAX); hmap_init(&tmp); if (new_mask) { @@ -261,3 +260,18 @@ hmap_at_position(const struct hmap *hmap, *offsetp = 0; return NULL; } + +/* Returns true if 'node' is in 'hmap', false otherwise. */ +bool +hmap_contains(const struct hmap *hmap, const struct hmap_node *node) +{ + struct hmap_node *p; + + for (p = hmap_first_in_bucket(hmap, node->hash); p; p = p->next) { + if (p == node) { + return true; + } + } + + return false; +}