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) {

View File

@@ -3,7 +3,8 @@ import grammer:*
import string:*
fun main():int {
var a = load_grammer(string("grammer.kgm"))
var a = load_grammer(string("../krakenGrammer.kgm"))
/*var a = load_grammer(string("grammer.kgm"))*/
println(a.to_string())
return 0
}

View File

@@ -1,6 +1,6 @@
import io:*
fun main():int {
var wr: fun():int*
return 0
}