array test_cs137 integer test_count819 array C_nextFree148 integer C_firstFree432 integer C_maxIndex303 array C_typeId138 array C_alive438 integer test_count819 = 0 integer C_firstFree432 = 0 integer C_maxIndex303 = 0 function initGlobals183() { C_firstFree_432 = 0; C_maxIndex_303 = 0; } function main207() { initGlobals183(); init_test305(); } function config382() { } function init_test305() { local integer i173 local integer j230 test_count_819 = 0; i_173 = 0; loop { exitwhen (i_173 > 1000); if ((test_count_819 < 100) and (GetRandomReal176(0., 1.) <= 0.5)) { test_cs_137[test_count_819] = new_C164(); test_count_819 = (test_count_819 + 1); } else { }; if ((test_count_819 > 0) and (GetRandomReal176(0., 1.) <= 0.1)) { j_230 = GetRandomInt979(0, (test_count_819 - 1)); dispatch_C_destroyC162(test_cs_137[j_230]); test_count_819 = (test_count_819 - 1); test_cs_137[j_230] = test_cs_137[test_count_819]; } else { }; i_173 = (i_173 + 1); }; testSuccess259(); } IS_NATIVE function testFail585(string msg666) { } IS_NATIVE IS_EXTERN @extern function GetRandomReal176(real a867, real b680) returns real { } IS_NATIVE IS_EXTERN @extern function GetRandomInt979(integer a198, integer b312) returns integer { } IS_NATIVE function testSuccess259() { } function C_init513(integer this405) { } function new_C164() returns integer { local integer this155 this_155 = alloc_C207(); construct_C739(this_155); return this_155; } function construct_C739(integer this308) { C_init513(this_308); if (C_alive_438[this_308] == 1) { testFail585("already alive"); } else { }; C_alive_438[this_308] = 1; } function C_onDestroy242(integer this166) { C_alive_438[this_166] = 2; } function destroyC974(integer this119) { C_onDestroy242(this_119); dealloc_C207(this_119); } function alloc_C207() returns integer { local integer this158 if (C_firstFree_432 == 0) { if (C_maxIndex_303 < 32768) { C_maxIndex_303 = (C_maxIndex_303 + 1); this_158 = C_maxIndex_303; C_typeId_138[this_158] = 1; } else { error201("Out of memory: Could not create C."); this_158 = 0; }; } else { C_firstFree_432 = (C_firstFree_432 - 1); this_158 = C_nextFree_148[C_firstFree_432]; C_typeId_138[this_158] = 1; }; return this_158; } function error201(string msg131) { $debugPrint455((msg_131 + (" " + #getStackTrace()))); } function dealloc_C207(integer obj450) { if (C_typeId_138[obj_450] == 0) { error201("Double free: object of type C"); } else { C_nextFree_148[C_firstFree_432] = obj_450; C_firstFree_432 = (C_firstFree_432 + 1); C_typeId_138[obj_450] = 0; }; } function dispatch_C_destroyC162(integer this794) { if (C_typeId_138[this_794] == 0) { if (this_794 == 0) { error201("Nullpointer exception when calling C.C"); } else { error201("Called C.C on invalid object."); }; } else { }; destroyC974(this_794); }