array A_nextFree896 integer A_firstFree128 integer A_maxIndex259 array A_typeId162 integer A_firstFree128 = 0 integer A_maxIndex259 = 0 function initGlobals133() { A_firstFree_128 = 0; A_maxIndex_259 = 0; } function main141() { initGlobals133(); init_Test120(); } function config118() { } function init_Test120() { local integer a354 local integer e169 local integer count1895 local integer count2164 a_354 = new_A123(); new_A123(); new_A123(); new_A123(); e_169 = new_A123(); count1_895 = maxInstanceCount548(1); dispatch_A_destroyA518(a_354); dispatch_A_destroyA518(e_169); count2_164 = maxInstanceCount548(1); if ((count1_895 == 5) and (count2_164 == 5)) { testSuccess819(); } else { }; } IS_NATIVE function testSuccess819() { } function A_init203(integer this170) { } function new_A123() returns integer { local integer this120 this_120 = alloc_A787(); construct_A969(this_120); return this_120; } function construct_A969(integer this108) { A_init203(this_108); } function A_onDestroy137(integer this156) { } function destroyA181(integer this340) { A_onDestroy137(this_340); dealloc_A213(this_340); } function maxInstanceCount548(integer typeId129) returns integer { return A_maxIndex_259; return 0; } function alloc_A787() returns integer { local integer this116 if (A_firstFree_128 == 0) { if (A_maxIndex_259 < 32768) { A_maxIndex_259 = (A_maxIndex_259 + 1); this_116 = A_maxIndex_259; A_typeId_162[this_116] = 1; } else { error187("Out of memory: Could not create A."); this_116 = 0; }; } else { A_firstFree_128 = (A_firstFree_128 - 1); this_116 = A_nextFree_896[A_firstFree_128]; A_typeId_162[this_116] = 1; }; return this_116; } function error187(string msg146) { $debugPrint325((msg_146 + (" " + #getStackTrace()))); } function dealloc_A213(integer obj199) { if (A_typeId_162[obj_199] == 0) { error187("Double free: object of type A"); } else { A_nextFree_896[A_firstFree_128] = obj_199; A_firstFree_128 = (A_firstFree_128 + 1); A_typeId_162[obj_199] = 0; }; } function dispatch_A_destroyA518(integer this896) { if (A_typeId_162[this_896] == 0) { if (this_896 == 0) { error187("Nullpointer exception when calling A.A"); } else { error187("Called A.A on invalid object."); }; } else { }; destroyA181(this_896); }