Skip to content
Snippets Groups Projects
Commit 5ae6042a authored by David Vasek's avatar David Vasek
Browse files

dynarray: when removing an item by replacing it with the last one, check that item too

This prevents a situtation when the deleted item may repeat in the array.
This solution is based on the assumption that the duplicate entries are rather rare.
parent 4ea301c6
No related branches found
No related tags found
1 merge request!1392dynarray: remove even duplicate items
......@@ -128,7 +128,7 @@
knot_dynarray_foreach(prefix, ntype, removable, *dynarray) { \
if (memcmp(removable, to_remove, sizeof(*to_remove)) == 0) { \
if (removable != orig_arr + --dynarray->size) { \
*removable = orig_arr[dynarray->size]; \
*(removable--) = orig_arr[dynarray->size]; \
} \
} \
} /* TODO enable lowering capacity, take care of capacity going back to initial! */ \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment