diff options
author | Jarno Rajahalme <jarno@ovn.org> | 2016-07-29 11:04:48 -0700 |
---|---|---|
committer | Jarno Rajahalme <jarno@ovn.org> | 2016-07-29 11:11:14 -0700 |
commit | 93f25605e49e106c1b05babd21923d5ad6bb551b (patch) | |
tree | f60c3785e68ae6c4ef83486915a19b9c8416f2cb /lib/pvector.c | |
parent | 3d0dc308a46e1e05aaec454f94e0129b811cb3c2 (diff) | |
download | openvswitch-93f25605e49e106c1b05babd21923d5ad6bb551b.tar.gz |
pvector: Get rid of special purpose of INT_MIN.
Allow clients to use the whole priority range. Note that this changes
the semantics of PVECTOR_FOR_EACH_PRIORITY so that the iteration still
continues for entries at the given priority.
Suggested-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib/pvector.c')
-rw-r--r-- | lib/pvector.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/pvector.c b/lib/pvector.c index 04c2e65e9..aaeee9214 100644 --- a/lib/pvector.c +++ b/lib/pvector.c @@ -95,10 +95,6 @@ static void pvector_impl_sort(struct pvector_impl *impl) { qsort(impl->vector, impl->size, sizeof *impl->vector, pvector_entry_cmp); - /* Trim gaps. */ - while (impl->size && impl->vector[impl->size - 1].priority == INT_MIN) { - impl->size = impl->size - 1; - } } /* Returns the index of the 'ptr' in the vector, or -1 if none is found. */ @@ -163,9 +159,11 @@ pvector_remove(struct pvector *pvec, void *ptr) index = pvector_impl_find(temp, ptr); ovs_assert(index >= 0); /* Now at the index of the entry to be deleted. - * Clear in place, publish will sort and clean these off. */ - temp->vector[index].ptr = NULL; - temp->vector[index].priority = INT_MIN; + * Swap another entry in if needed, publish will sort anyway. */ + temp->size--; + if (index != temp->size) { + temp->vector[index] = temp->vector[temp->size]; + } } /* Change entry's 'priority' and keep the vector ordered. */ |