array A_nextFree204 integer A_firstFree138 integer A_maxIndex121 array A_typeId211 integer A_firstFree138 = 0 integer A_maxIndex121 = 0 function initGlobals503() { } function main169() { initGlobals503(); init_Test870(); } function config212() { } function init_Test870() { local integer a115 local integer e269 local integer count1171 local integer count2187 a_115 = new_A997(); new_A997(); new_A997(); new_A997(); e_269 = new_A997(); count1_171 = maxInstanceCount112(1); dispatch_A_destroyA189(a_115); dispatch_A_destroyA189(e_269); count2_187 = maxInstanceCount112(1); if ((count1_171 == 5) and (count2_187 == 5)) { testSuccess501(); } else { }; } IS_NATIVE function testSuccess501() { } function new_A997() returns integer { local integer this179 local integer this121 if (A_firstFree_138 == 0) { if (A_maxIndex_121 < 32768) { A_maxIndex_121 = (A_maxIndex_121 + 1); this_121 = A_maxIndex_121; A_typeId_211[this_121] = 1; } else { error194("Out of memory: Could not create A."); this_121 = 0; }; } else { A_firstFree_138 = (A_firstFree_138 - 1); this_121 = A_nextFree_204[A_firstFree_138]; A_typeId_211[this_121] = 1; }; this_179 = this_121; return this_179; } function maxInstanceCount112(integer typeId207) returns integer { return A_maxIndex_121; return 0; } function error194(string msg199) { $debugPrint745((msg_199 + (" " + #getStackTrace()))); } function dispatch_A_destroyA189(integer this156) { local integer this895 local integer obj181 if (A_typeId_211[this_156] == 0) { if (this_156 == 0) { error194("Nullpointer exception when calling A.A"); } else { error194("Called A.A on invalid object."); }; } else { }; this_895 = this_156; obj_181 = this_895; if (A_typeId_211[obj_181] == 0) { error194("Double free: object of type A"); } else { A_nextFree_204[A_firstFree_138] = obj_181; A_firstFree_138 = (A_firstFree_138 + 1); A_typeId_211[obj_181] = 0; }; }