Skip to content
Snippets Groups Projects
Commit fccbd1e3 authored by David Vasek's avatar David Vasek Committed by Daniel Salzman
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 6c23b239
No related branches found
No related tags found
No related merge requests found
......@@ -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