array A_nextFree450 integer A_firstFree180 integer A_maxIndex150 array A_typeId186 integer A_firstFree180 = 0 integer A_maxIndex150 = 0 function initGlobals106() { } function main101() { initGlobals106(); init_Test697(); } function config125() { } function init_Test697() { local integer a255 local integer e150 local integer count1342 local integer count2139 a_255 = new_A635(); new_A635(); new_A635(); new_A635(); e_150 = new_A635(); count1_342 = maxInstanceCount377(1); dispatch_A_destroyA184(a_255); dispatch_A_destroyA184(e_150); count2_139 = maxInstanceCount377(1); if ((count1_342 == 5) and (count2_139 == 5)) { testSuccess670(); } else { }; } IS_NATIVE function testSuccess670() { } function new_A635() returns integer { local integer this179 local integer this684 if (A_firstFree_180 == 0) { if (A_maxIndex_150 < 32768) { A_maxIndex_150 = (A_maxIndex_150 + 1); this_684 = A_maxIndex_150; A_typeId_186[this_684] = 1; } else { error109("Out of memory: Could not create A."); this_684 = 0; }; } else { A_firstFree_180 = (A_firstFree_180 - 1); this_684 = A_nextFree_450[A_firstFree_180]; A_typeId_186[this_684] = 1; }; this_179 = this_684; return this_179; } function maxInstanceCount377(integer typeId159) returns integer { return A_maxIndex_150; return 0; } function error109(string msg174) { $debugPrint192((msg_174 + (" " + #getStackTrace()))); } function dispatch_A_destroyA184(integer this896) { local integer this167 local integer obj560 if (A_typeId_186[this_896] == 0) { if (this_896 == 0) { error109("Nullpointer exception when calling A.A"); } else { error109("Called A.A on invalid object."); }; } else { }; this_167 = this_896; obj_560 = this_167; if (A_typeId_186[obj_560] == 0) { error109("Double free: object of type A"); } else { A_nextFree_450[A_firstFree_180] = obj_560; A_firstFree_180 = (A_firstFree_180 + 1); A_typeId_186[obj_560] = 0; }; }