/*
- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <config.h>
#include "hmap.h"
-#include <assert.h>
#include <stdint.h>
#include <string.h>
#include "coverage.h"
struct hmap tmp;
size_t i;
- assert(!(new_mask & (new_mask + 1)));
- assert(new_mask != SIZE_MAX);
+ ovs_assert(is_pow2(new_mask + 1));
hmap_init(&tmp);
if (new_mask) {
*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;
+}