-
- Downloads
fixup! NodeFragment: added remove methods
When a child is removed, the array may be reallocated, to not waste unused memory. If the child is removed out of the middle, all subsequent childs have to be moved. However, if it turns out that the reallocation is not currently possible, the method should return the NodeFragment in a state, as if the call to the remove method never happened. This means, that all the childs, that were moved before the realloc call, have to be moved back and the original child has also to be written back. This was forgotten, which is clearly a bug, which is fixed hereby. Note that it would be theoretically possible to not move everything back and forth, by storing the last value before the call to realloc and only in case of success move everything. While this is possible and more efficient, it is also a bit more complicated, and as this only takes effect, if the OS fails to provide memory, which should be an uncommon event, the algorithm is not changed, leaving that possible inefficient approach.
Loading
Please register or sign in to comment