X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fshash.c;h=a5bfecf04a0d53b4b8fdd28a6e718aef4495a040;hb=0d0f05b909b6428d44eb147bd4edd73782d2a137;hp=5257de12aad4c4df7acb03809224e1e0bdd70e0c;hpb=7634353824f1631c3008dc43a4a1cc0aebff3caa;p=openvswitch diff --git a/lib/shash.c b/lib/shash.c index 5257de12..a5bfecf0 100644 --- a/lib/shash.c +++ b/lib/shash.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 Nicira Networks. + * Copyright (c) 2009, 2010 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,18 @@ shash_destroy(struct shash *sh) } } +void +shash_swap(struct shash *a, struct shash *b) +{ + hmap_swap(&a->map, &b->map); +} + +void +shash_moved(struct shash *sh) +{ + hmap_moved(&sh->map); +} + void shash_clear(struct shash *sh) { @@ -168,3 +180,21 @@ shash_sort(const struct shash *sh) return nodes; } } + +/* Returns true if 'a' and 'b' contain the same keys (regardless of their + * values), false otherwise. */ +bool +shash_equal_keys(const struct shash *a, const struct shash *b) +{ + struct shash_node *node; + + if (hmap_count(&a->map) != hmap_count(&b->map)) { + return false; + } + SHASH_FOR_EACH (node, a) { + if (!shash_find(b, node->name)) { + return false; + } + } + return true; +}