// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1365 globals integer array test_b integer array Blub_nextFree integer Blub_firstFree=0 integer Blub_maxIndex=0 integer array Blub_typeId integer array Blub_x endglobals native testFail takes string msg returns nothing native testSuccess takes nothing returns nothing function initGlobals takes nothing returns nothing endfunction function error takes string msg returns nothing call BJDebugMsg(msg + "\n" + "") endfunction function dispatch_Blub_destroyBlub takes integer this returns nothing if Blub_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling Blub.Blub") else call error("Called Blub.Blub on invalid object.") endif endif if Blub_typeId[this] == 0 then call error("Double free: object of type Blub") else set Blub_nextFree[Blub_firstFree] = this set Blub_firstFree = Blub_firstFree + 1 set Blub_typeId[this] = 0 endif endfunction function init_test takes nothing returns nothing local integer this if Blub_firstFree == 0 then if Blub_maxIndex < 32768 then set Blub_maxIndex = Blub_maxIndex + 1 set this = Blub_maxIndex set Blub_typeId[this] = 1 else call error("Out of memory: Could not create Blub.") set this = 0 endif else set Blub_firstFree = Blub_firstFree - 1 set this = Blub_nextFree[Blub_firstFree] set Blub_typeId[this] = 1 endif set Blub_x[this] = 0 set test_b[0] = this if Blub_firstFree == 0 then if Blub_maxIndex < 32768 then set Blub_maxIndex = Blub_maxIndex + 1 set this = Blub_maxIndex set Blub_typeId[this] = 1 else call error("Out of memory: Could not create Blub.") set this = 0 endif else set Blub_firstFree = Blub_firstFree - 1 set this = Blub_nextFree[Blub_firstFree] set Blub_typeId[this] = 1 endif set Blub_x[this] = 1 set test_b[1] = this if Blub_firstFree == 0 then if Blub_maxIndex < 32768 then set Blub_maxIndex = Blub_maxIndex + 1 set this = Blub_maxIndex set Blub_typeId[this] = 1 else call error("Out of memory: Could not create Blub.") set this = 0 endif else set Blub_firstFree = Blub_firstFree - 1 set this = Blub_nextFree[Blub_firstFree] set Blub_typeId[this] = 1 endif set Blub_x[this] = 2 set test_b[2] = this if Blub_firstFree == 0 then if Blub_maxIndex < 32768 then set Blub_maxIndex = Blub_maxIndex + 1 set this = Blub_maxIndex set Blub_typeId[this] = 1 else call error("Out of memory: Could not create Blub.") set this = 0 endif else set Blub_firstFree = Blub_firstFree - 1 set this = Blub_nextFree[Blub_firstFree] set Blub_typeId[this] = 1 endif set Blub_x[this] = 3 set test_b[3] = this if Blub_firstFree == 0 then if Blub_maxIndex < 32768 then set Blub_maxIndex = Blub_maxIndex + 1 set this = Blub_maxIndex set Blub_typeId[this] = 1 else call error("Out of memory: Could not create Blub.") set this = 0 endif else set Blub_firstFree = Blub_firstFree - 1 set this = Blub_nextFree[Blub_firstFree] set Blub_typeId[this] = 1 endif set Blub_x[this] = 4 set test_b[4] = this if Blub_firstFree == 0 then if Blub_maxIndex < 32768 then set Blub_maxIndex = Blub_maxIndex + 1 set this = Blub_maxIndex set Blub_typeId[this] = 1 else call error("Out of memory: Could not create Blub.") set this = 0 endif else set Blub_firstFree = Blub_firstFree - 1 set this = Blub_nextFree[Blub_firstFree] set Blub_typeId[this] = 1 endif set Blub_x[this] = 5 set test_b[5] = this if Blub_firstFree == 0 then if Blub_maxIndex < 32768 then set Blub_maxIndex = Blub_maxIndex + 1 set this = Blub_maxIndex set Blub_typeId[this] = 1 else call error("Out of memory: Could not create Blub.") set this = 0 endif else set Blub_firstFree = Blub_firstFree - 1 set this = Blub_nextFree[Blub_firstFree] set Blub_typeId[this] = 1 endif set Blub_x[this] = 6 set test_b[6] = this if Blub_firstFree == 0 then if Blub_maxIndex < 32768 then set Blub_maxIndex = Blub_maxIndex + 1 set this = Blub_maxIndex set Blub_typeId[this] = 1 else call error("Out of memory: Could not create Blub.") set this = 0 endif else set Blub_firstFree = Blub_firstFree - 1 set this = Blub_nextFree[Blub_firstFree] set Blub_typeId[this] = 1 endif set Blub_x[this] = 7 set test_b[7] = this call dispatch_Blub_destroyBlub(test_b[0]) call dispatch_Blub_destroyBlub(test_b[6]) call dispatch_Blub_destroyBlub(test_b[2]) call dispatch_Blub_destroyBlub(test_b[4]) if Blub_firstFree == 0 then if Blub_maxIndex < 32768 then set Blub_maxIndex = Blub_maxIndex + 1 set this = Blub_maxIndex set Blub_typeId[this] = 1 else call error("Out of memory: Could not create Blub.") set this = 0 endif else set Blub_firstFree = Blub_firstFree - 1 set this = Blub_nextFree[Blub_firstFree] set Blub_typeId[this] = 1 endif set Blub_x[this] = 8 set test_b[8] = this if Blub_firstFree == 0 then if Blub_maxIndex < 32768 then set Blub_maxIndex = Blub_maxIndex + 1 set this = Blub_maxIndex set Blub_typeId[this] = 1 else call error("Out of memory: Could not create Blub.") set this = 0 endif else set Blub_firstFree = Blub_firstFree - 1 set this = Blub_nextFree[Blub_firstFree] set Blub_typeId[this] = 1 endif set Blub_x[this] = 9 set test_b[9] = this set this = 0 loop exitwhen this >= 10 if ModuloInteger(this, 2) == 1 and Blub_x[test_b[this]] != this then call testFail("fail " + I2S(this) + ", " + I2S(Blub_x[test_b[this]])) endif set this = this + 1 endloop call testSuccess() endfunction function main takes nothing returns nothing call initGlobals() call init_test() endfunction function config takes nothing returns nothing endfunction