array A_nextFree145 integer A_firstFree121 integer A_maxIndex209 array A_typeId204 integer A_firstFree121 = 0 integer A_maxIndex209 = 0 function initGlobals175() { } function main182() { initGlobals175(); init_Test627(); } function config202() { } function init_Test627() { local integer a152 local integer e103 local integer count1893 a_152 = new_A107(); new_A107(); new_A107(); new_A107(); e_103 = new_A107(); count1_893 = maxInstanceCount185(1); dispatch_A_destroyA178(a_152); dispatch_A_destroyA178(e_103); e_103 = maxInstanceCount185(1); if ((count1_893 == 5) and (e_103 == 5)) { testSuccess185(); } else { }; } IS_NATIVE function testSuccess185() { } function new_A107() returns integer { local integer this152 if (A_firstFree_121 == 0) { if (A_maxIndex_209 < 32768) { A_maxIndex_209 = (A_maxIndex_209 + 1); this_152 = A_maxIndex_209; A_typeId_204[this_152] = 1; } else { error124("Out of memory: Could not create A."); this_152 = 0; }; } else { A_firstFree_121 = (A_firstFree_121 - 1); this_152 = A_nextFree_145[A_firstFree_121]; A_typeId_204[this_152] = 1; }; return this_152; } function maxInstanceCount185(integer typeId417) returns integer { return A_maxIndex_209; } function error124(string msg734) { $debugPrint112((msg_734 + (" " + #getStackTrace()))); } function dispatch_A_destroyA178(integer this102) { if (A_typeId_204[this_102] == 0) { if (this_102 == 0) { error124("Nullpointer exception when calling A.A"); } else { error124("Called A.A on invalid object."); }; } else { }; if (A_typeId_204[this_102] == 0) { error124("Double free: object of type A"); } else { A_nextFree_145[A_firstFree_121] = this_102; A_firstFree_121 = (A_firstFree_121 + 1); A_typeId_204[this_102] = 0; }; }