array test_cs181 integer test_count461 array C_nextFree197 integer C_firstFree132 integer C_maxIndex943 array C_typeId428 array C_alive142 integer test_count461 = 0 integer C_firstFree132 = 0 integer C_maxIndex943 = 0 function initGlobals182() { } function main181() { initGlobals182(); init_test963(); } function config675() { } function init_test963() { local integer i170 local integer j168 test_count_461 = 0; i_170 = 0; loop { exitwhen (i_170 > 1000); if ((test_count_461 < 100) and (GetRandomReal101(0., 1.) <= 0.5)) { test_cs_181[test_count_461] = new_C105(); test_count_461 = (test_count_461 + 1); } else { }; if ((test_count_461 > 0) and (GetRandomReal101(0., 1.) <= 0.1)) { j_168 = GetRandomInt479(0, (test_count_461 - 1)); dispatch_C_destroyC238(test_cs_181[j_168]); test_count_461 = (test_count_461 - 1); test_cs_181[j_168] = test_cs_181[test_count_461]; } else { }; i_170 = (i_170 + 1); }; testSuccess201(); } IS_NATIVE function testFail130(string msg195) { } IS_NATIVE IS_EXTERN @extern function GetRandomReal101(real a119, real b172) returns real { } IS_NATIVE IS_EXTERN @extern function GetRandomInt479(integer a703, integer b931) returns integer { } IS_NATIVE function testSuccess201() { } function C_init182(integer this140) { } function new_C105() returns integer { local integer this176 this_176 = alloc_C116(); construct_C120(this_176); return this_176; } function construct_C120(integer this122) { C_init182(this_122); if (C_alive_142[this_122] == 1) { testFail130("already alive"); } else { }; C_alive_142[this_122] = 1; } function C_onDestroy182(integer this687) { C_alive_142[this_687] = 2; } function destroyC560(integer this246) { C_onDestroy182(this_246); dealloc_C178(this_246); } function alloc_C116() returns integer { local integer this149 if (C_firstFree_132 == 0) { if (C_maxIndex_943 < 32768) { C_maxIndex_943 = (C_maxIndex_943 + 1); this_149 = C_maxIndex_943; C_typeId_428[this_149] = 1; } else { error112("Out of memory: Could not create C."); this_149 = 0; }; } else { C_firstFree_132 = (C_firstFree_132 - 1); this_149 = C_nextFree_197[C_firstFree_132]; C_typeId_428[this_149] = 1; }; return this_149; } function error112(string msg141) { $debugPrint101((msg_141 + (" " + #getStackTrace()))); } function dealloc_C178(integer obj159) { if (C_typeId_428[obj_159] == 0) { error112("Double free: object of type C"); } else { C_nextFree_197[C_firstFree_132] = obj_159; C_firstFree_132 = (C_firstFree_132 + 1); C_typeId_428[obj_159] = 0; }; } function dispatch_C_destroyC238(integer this184) { if (C_typeId_428[this_184] == 0) { if (this_184 == 0) { error112("Nullpointer exception when calling C.C"); } else { error112("Called C.C on invalid object."); }; } else { }; destroyC560(this_184); }