array A_nextFree202 integer A_firstFree345 integer A_maxIndex839 array A_typeId123 integer A_firstFree345 = 0 integer A_maxIndex839 = 0 function initGlobals254() { } function main785() { initGlobals254(); init_Test159(); } function config180() { } function init_Test159() { local integer a117 local integer e627 local integer count1770 local integer count2866 a_117 = new_A706(); new_A706(); new_A706(); new_A706(); e_627 = new_A706(); count1_770 = instanceCount142(1); dispatch_A_destroyA140(a_117); dispatch_A_destroyA140(e_627); count2_866 = instanceCount142(1); if ((count1_770 == 5) and (count2_866 == 3)) { testSuccess109(); } else { }; } IS_NATIVE function testSuccess109() { } function new_A706() returns integer { local integer this131 local integer this104 if (A_firstFree_345 == 0) { if (A_maxIndex_839 < 32768) { A_maxIndex_839 = (A_maxIndex_839 + 1); this_104 = A_maxIndex_839; A_typeId_123[this_104] = 1; } else { error196("Out of memory: Could not create A."); this_104 = 0; }; } else { A_firstFree_345 = (A_firstFree_345 - 1); this_104 = A_nextFree_202[A_firstFree_345]; A_typeId_123[this_104] = 1; }; this_131 = this_104; return this_131; } function instanceCount142(integer typeId398) returns integer { return (A_maxIndex_839 - A_firstFree_345); return 0; } function error196(string msg202) { $debugPrint206((msg_202 + (" " + #getStackTrace()))); } function dispatch_A_destroyA140(integer this155) { local integer this115 local integer obj132 if (A_typeId_123[this_155] == 0) { if (this_155 == 0) { error196("Nullpointer exception when calling A.A"); } else { error196("Called A.A on invalid object."); }; } else { }; this_115 = this_155; obj_132 = this_115; if (A_typeId_123[obj_132] == 0) { error196("Double free: object of type A"); } else { A_nextFree_202[A_firstFree_345] = obj_132; A_firstFree_345 = (A_firstFree_345 + 1); A_typeId_123[obj_132] = 0; }; }