Fix vector addEnd so that it increments size AFTER the resize and resize() doesn't copy_construct an invalid item, which only SOMETIMES failes

This commit is contained in:
Nathan Braswell
2015-07-04 12:59:05 -04:00
parent bd5e0af00f
commit d2b12fea35
3 changed files with 6 additions and 5 deletions

View File

@@ -142,10 +142,10 @@ obj vector<T> (Object) {
}
fun add(dataIn: T): void { addEnd(dataIn); }
fun addEnd(dataIn: T): void {
if (size+1 >= available)
resize((size+1)*2);
maybe_copy_construct(&data[size], &dataIn);
size++;
if (size >= available)
resize(size*2);
maybe_copy_construct(&data[size-1], &dataIn);
}
fun remove(index: int) {