array A_nextFree212 integer A_firstFree131 integer A_maxIndex120 array A_typeId550 integer A_firstFree131 = 0 integer A_maxIndex120 = 0 function initGlobals133() { } function main106() { initGlobals133(); init_Test118(); } function config138() { } function init_Test118() { local integer a219 local integer e121 local integer count1955 local integer count2185 a_219 = new_A105(); new_A105(); new_A105(); new_A105(); e_121 = new_A105(); count1_955 = instanceCount184(1); dispatch_A_destroyA155(a_219); dispatch_A_destroyA155(e_121); count2_185 = instanceCount184(1); if ((count1_955 == 5) and (count2_185 == 3)) { testSuccess214(); } else { }; } IS_NATIVE function testSuccess214() { } function new_A105() returns integer { local integer this112 local integer this204 if (A_firstFree_131 == 0) { if (A_maxIndex_120 < 32768) { A_maxIndex_120 = (A_maxIndex_120 + 1); this_204 = A_maxIndex_120; A_typeId_550[this_204] = 1; } else { error428("Out of memory: Could not create A."); this_204 = 0; }; } else { A_firstFree_131 = (A_firstFree_131 - 1); this_204 = A_nextFree_212[A_firstFree_131]; A_typeId_550[this_204] = 1; }; this_112 = this_204; return this_112; } function instanceCount184(integer typeId175) returns integer { return (A_maxIndex_120 - A_firstFree_131); return 0; } function error428(string msg526) { $debugPrint158((msg_526 + (" " + #getStackTrace()))); } function dispatch_A_destroyA155(integer this155) { local integer this114 local integer obj106 if (A_typeId_550[this_155] == 0) { if (this_155 == 0) { error428("Nullpointer exception when calling A.A"); } else { error428("Called A.A on invalid object."); }; } else { }; this_114 = this_155; obj_106 = this_114; if (A_typeId_550[obj_106] == 0) { error428("Double free: object of type A"); } else { A_nextFree_212[A_firstFree_131] = obj_106; A_firstFree_131 = (A_firstFree_131 + 1); A_typeId_550[obj_106] = 0; }; }