array C_nextFree440 integer C_firstFree908 integer C_maxIndex133 array C_typeId204 integer C_firstFree908 = 0 integer C_maxIndex133 = 0 function initGlobals184() { C_firstFree_908 = 0; C_maxIndex_133 = 0; } function main632() { initGlobals184(); init_test763(); } function config401() { } function init_test763() { local array cs937 local integer i498 local integer j389 local integer k143 i_498 = 0; loop { exitwhen (i_498 > 6000); cs_937[i_498] = new_C130(); i_498 = (i_498 + 1); }; j_389 = 0; loop { exitwhen (j_389 > 6000); dispatch_C_destroyC195(cs_937[j_389]); j_389 = (j_389 + 1); }; k_143 = 0; loop { exitwhen (k_143 > 6000); cs_937[k_143] = new_C130(); k_143 = (k_143 + 1); }; if ((cs_937[6000] castTo integer) <= 6001) { testSuccess143(); } else { }; } IS_NATIVE function testSuccess143() { } function C_init154(integer this202) { } function new_C130() returns integer { local integer this117 this_117 = alloc_C136(); construct_C143(this_117); return this_117; } function construct_C143(integer this179) { C_init154(this_179); } function C_onDestroy164(integer this141) { } function destroyC136(integer this781) { C_onDestroy164(this_781); dealloc_C545(this_781); } function alloc_C136() returns integer { local integer this132 if (C_firstFree_908 == 0) { if (C_maxIndex_133 < 32768) { C_maxIndex_133 = (C_maxIndex_133 + 1); this_132 = C_maxIndex_133; C_typeId_204[this_132] = 1; } else { error174("Out of memory: Could not create C."); this_132 = 0; }; } else { C_firstFree_908 = (C_firstFree_908 - 1); this_132 = C_nextFree_440[C_firstFree_908]; C_typeId_204[this_132] = 1; }; return this_132; } function error174(string msg565) { $debugPrint145((msg_565 + (" " + #getStackTrace()))); } function dealloc_C545(integer obj138) { if (C_typeId_204[obj_138] == 0) { error174("Double free: object of type C"); } else { C_nextFree_440[C_firstFree_908] = obj_138; C_firstFree_908 = (C_firstFree_908 + 1); C_typeId_204[obj_138] = 0; }; } function dispatch_C_destroyC195(integer this197) { if (C_typeId_204[this_197] == 0) { if (this_197 == 0) { error174("Nullpointer exception when calling C.C"); } else { error174("Called C.C on invalid object."); }; } else { }; destroyC136(this_197); }