array A_nextFree126 integer A_firstFree468 integer A_maxIndex130 array A_typeId199 integer A_firstFree468 = 0 integer A_maxIndex130 = 0 function initGlobals188() { } function main166() { initGlobals188(); init_Test155(); } function config424() { } function init_Test155() { local integer a138 local integer e890 local integer count1645 a_138 = new_A874(); new_A874(); new_A874(); new_A874(); e_890 = new_A874(); count1_645 = maxInstanceCount432(1); dispatch_A_destroyA566(a_138); dispatch_A_destroyA566(e_890); e_890 = maxInstanceCount432(1); if ((count1_645 == 5) and (e_890 == 5)) { testSuccess120(); } else { }; } IS_NATIVE function testSuccess120() { } function new_A874() returns integer { local integer this181 if (A_firstFree_468 == 0) { if (A_maxIndex_130 < 32768) { A_maxIndex_130 = (A_maxIndex_130 + 1); this_181 = A_maxIndex_130; A_typeId_199[this_181] = 1; } else { error591("Out of memory: Could not create A."); this_181 = 0; }; } else { A_firstFree_468 = (A_firstFree_468 - 1); this_181 = A_nextFree_126[A_firstFree_468]; A_typeId_199[this_181] = 1; }; return this_181; } function maxInstanceCount432(integer typeId148) returns integer { return A_maxIndex_130; } function error591(string msg136) { $debugPrint357((msg_136 + (" " + #getStackTrace()))); } function dispatch_A_destroyA566(integer this166) { if (A_typeId_199[this_166] == 0) { if (this_166 == 0) { error591("Nullpointer exception when calling A.A"); } else { error591("Called A.A on invalid object."); }; } else { }; if (A_typeId_199[this_166] == 0) { error591("Double free: object of type A"); } else { A_nextFree_126[A_firstFree_468] = this_166; A_firstFree_468 = (A_firstFree_468 + 1); A_typeId_199[this_166] = 0; }; }