This will acquire a user in an upcoming commit. Signed-off-by: Ben Pfaff <b...@ovn.org> --- lib/simap.c | 21 ++++++++++++++++++++- lib/simap.h | 4 +++- 2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/lib/simap.c b/lib/simap.c index 9c30f6886b2f..157819ea3970 100644 --- a/lib/simap.c +++ b/lib/simap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc. + * Copyright (c) 2009, 2010, 2011, 2012, 2017 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -222,6 +222,25 @@ simap_sort(const struct simap *simap) return nodes; } } + +/* Returns true if the two maps are equal, meaning that they have the same set + * of key-value pairs, otherwise false. */ +bool +simap_equal(const struct simap *a, const struct simap *b) +{ + if (simap_count(a) != simap_count(b)) { + return false; + } + + const struct simap_node *an; + SIMAP_FOR_EACH (an, a) { + const struct simap_node *bn = simap_find(b, an->name); + if (!bn || an->data != bn->data) { + return false; + } + } + return true; +} static size_t hash_name(const char *name, size_t length) diff --git a/lib/simap.h b/lib/simap.h index 9486080f4ded..76203740e1a2 100644 --- a/lib/simap.h +++ b/lib/simap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011, 2012, 2016 Nicira, Inc. + * Copyright (c) 2009, 2010, 2011, 2012, 2016, 2017 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,6 +70,8 @@ bool simap_find_and_delete(struct simap *, const char *); const struct simap_node **simap_sort(const struct simap *); +bool simap_equal(const struct simap *, const struct simap *); + #ifdef __cplusplus } #endif -- 2.10.2 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev