diff options
author | Ben Pfaff <blp@nicira.com> | 2010-01-28 14:21:31 -0800 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2010-01-28 16:06:31 -0800 |
commit | baa8f41b24179704944f278b5ae00231b1ca8246 (patch) | |
tree | d41f3387d716a875af176f6019992e41e326a53c /lib/hmap.c | |
parent | 63e60b866ffee6895e1772da2c48591ab2767aa7 (diff) | |
download | openvswitch-baa8f41b24179704944f278b5ae00231b1ca8246.tar.gz |
New functions hmap_moved(), shash_moved().
To be used in ovs-vsctl in an upcoming commit.
Diffstat (limited to 'lib/hmap.c')
-rw-r--r-- | lib/hmap.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/hmap.c b/lib/hmap.c index d66cf271a..71943a74e 100644 --- a/lib/hmap.c +++ b/lib/hmap.c @@ -48,11 +48,17 @@ hmap_swap(struct hmap *a, struct hmap *b) struct hmap tmp = *a; *a = *b; *b = tmp; - if (a->buckets == &b->one) { - a->buckets = &a->one; - } - if (b->buckets == &a->one) { - b->buckets = &b->one; + hmap_moved(a); + hmap_moved(b); +} + +/* Adjusts 'hmap' to compensate for having moved position in memory (e.g. due + * to realloc()). */ +void +hmap_moved(struct hmap *hmap) +{ + if (!hmap->mask) { + hmap->buckets = &hmap->one; } } |