array A_nextFree181 integer A_firstFree106 integer A_maxIndex340 array A_typeId208 integer A_firstFree106 = 0 integer A_maxIndex340 = 0 function initGlobals615() { A_firstFree_106 = 0; A_maxIndex_340 = 0; } function main200() { initGlobals615(); init_Test323(); } function config125() { } function init_Test323() { local integer a487 local integer e106 local integer count1153 local integer count2202 a_487 = new_A212(); new_A212(); new_A212(); new_A212(); e_106 = new_A212(); count1_153 = instanceCount111(1); dispatch_A_destroyA161(a_487); dispatch_A_destroyA161(e_106); count2_202 = instanceCount111(1); if ((count1_153 == 5) and (count2_202 == 3)) { testSuccess116(); } else { }; } IS_NATIVE function testSuccess116() { } function A_init149(integer this905) { } function new_A212() returns integer { local integer this104 this_104 = alloc_A146(); construct_A122(this_104); return this_104; } function construct_A122(integer this100) { A_init149(this_100); } function A_onDestroy371(integer this194) { } function destroyA189(integer this420) { A_onDestroy371(this_420); dealloc_A110(this_420); } function instanceCount111(integer typeId115) returns integer { return (A_maxIndex_340 - A_firstFree_106); return 0; } function alloc_A146() returns integer { local integer this123 if (A_firstFree_106 == 0) { if (A_maxIndex_340 < 32768) { A_maxIndex_340 = (A_maxIndex_340 + 1); this_123 = A_maxIndex_340; A_typeId_208[this_123] = 1; } else { error128("Out of memory: Could not create A."); this_123 = 0; }; } else { A_firstFree_106 = (A_firstFree_106 - 1); this_123 = A_nextFree_181[A_firstFree_106]; A_typeId_208[this_123] = 1; }; return this_123; } function error128(string msg133) { $debugPrint484((msg_133 + (" " + #getStackTrace()))); } function dealloc_A110(integer obj536) { if (A_typeId_208[obj_536] == 0) { error128("Double free: object of type A"); } else { A_nextFree_181[A_firstFree_106] = obj_536; A_firstFree_106 = (A_firstFree_106 + 1); A_typeId_208[obj_536] = 0; }; } function dispatch_A_destroyA161(integer this119) { if (A_typeId_208[this_119] == 0) { if (this_119 == 0) { error128("Nullpointer exception when calling A.A"); } else { error128("Called A.A on invalid object."); }; } else { }; destroyA189(this_119); }