array C_nextFree945 integer C_firstFree155 integer C_maxIndex771 array C_typeId130 integer C_firstFree155 = 0 integer C_maxIndex771 = 0 function initGlobals134() { C_firstFree_155 = 0; C_maxIndex_771 = 0; } function main211() { initGlobals134(); init_test114(); } function config166() { } function init_test114() { local array cs137 local integer i203 local integer j871 local integer k623 i_203 = 0; loop { exitwhen (i_203 > 6000); cs_137[i_203] = new_C206(); i_203 = (i_203 + 1); }; j_871 = 0; loop { exitwhen (j_871 > 6000); dispatch_C_destroyC188(cs_137[j_871]); j_871 = (j_871 + 1); }; k_623 = 0; loop { exitwhen (k_623 > 6000); cs_137[k_623] = new_C206(); k_623 = (k_623 + 1); }; if ((cs_137[6000] castTo integer) <= 6001) { testSuccess837(); } else { }; } IS_NATIVE function testSuccess837() { } function C_init749(integer this104) { } function new_C206() returns integer { local integer this117 this_117 = alloc_C983(); construct_C118(this_117); return this_117; } function construct_C118(integer this315) { C_init749(this_315); } function C_onDestroy135(integer this112) { } function destroyC479(integer this668) { C_onDestroy135(this_668); dealloc_C363(this_668); } function alloc_C983() returns integer { local integer this148 if (C_firstFree_155 == 0) { if (C_maxIndex_771 < 32768) { C_maxIndex_771 = (C_maxIndex_771 + 1); this_148 = C_maxIndex_771; C_typeId_130[this_148] = 1; } else { error175("Out of memory: Could not create C."); this_148 = 0; }; } else { C_firstFree_155 = (C_firstFree_155 - 1); this_148 = C_nextFree_945[C_firstFree_155]; C_typeId_130[this_148] = 1; }; return this_148; } function error175(string msg201) { $debugPrint453((msg_201 + (" " + #getStackTrace()))); } function dealloc_C363(integer obj604) { if (C_typeId_130[obj_604] == 0) { error175("Double free: object of type C"); } else { C_nextFree_945[C_firstFree_155] = obj_604; C_firstFree_155 = (C_firstFree_155 + 1); C_typeId_130[obj_604] = 0; }; } function dispatch_C_destroyC188(integer this184) { if (C_typeId_130[this_184] == 0) { if (this_184 == 0) { error175("Nullpointer exception when calling C.C"); } else { error175("Called C.C on invalid object."); }; } else { }; destroyC479(this_184); }