array test_cs163 integer test_count122 array C_nextFree511 integer C_firstFree198 integer C_maxIndex133 array C_typeId319 array C_alive109 integer test_count122 = 0 integer C_firstFree198 = 0 integer C_maxIndex133 = 0 function initGlobals174() { } function main103() { initGlobals174(); init_test390(); } function config206() { } function init_test390() { local integer i488 local integer j797 test_count_122 = 0; i_488 = 0; loop { exitwhen (i_488 > 1000); if ((test_count_122 < 100) and (GetRandomReal154(0., 1.) <= 0.5)) { test_cs_163[test_count_122] = new_C209(); test_count_122 = (test_count_122 + 1); } else { }; if ((test_count_122 > 0) and (GetRandomReal154(0., 1.) <= 0.1)) { j_797 = GetRandomInt460(0, (test_count_122 - 1)); dispatch_C_destroyC120(test_cs_163[j_797]); test_count_122 = (test_count_122 - 1); test_cs_163[j_797] = test_cs_163[test_count_122]; } else { }; i_488 = (i_488 + 1); }; testSuccess769(); } IS_NATIVE function testFail362(string msg175) { } IS_NATIVE IS_EXTERN @extern function GetRandomReal154(real a333, real b364) returns real { } IS_NATIVE IS_EXTERN @extern function GetRandomInt460(integer a183, integer b101) returns integer { } IS_NATIVE function testSuccess769() { } function new_C209() returns integer { local integer this118 if (C_firstFree_198 == 0) { if (C_maxIndex_133 < 32768) { C_maxIndex_133 = (C_maxIndex_133 + 1); this_118 = C_maxIndex_133; C_typeId_319[this_118] = 1; } else { error113("Out of memory: Could not create C."); this_118 = 0; }; } else { C_firstFree_198 = (C_firstFree_198 - 1); this_118 = C_nextFree_511[C_firstFree_198]; C_typeId_319[this_118] = 1; }; if (C_alive_109[this_118] == 1) { testFail362("already alive"); } else { }; C_alive_109[this_118] = 1; return this_118; } function error113(string msg119) { $debugPrint184((msg_119 + (" " + #getStackTrace()))); } function dispatch_C_destroyC120(integer this120) { if (C_typeId_319[this_120] == 0) { if (this_120 == 0) { error113("Nullpointer exception when calling C.C"); } else { error113("Called C.C on invalid object."); }; } else { }; C_alive_109[this_120] = 2; if (C_typeId_319[this_120] == 0) { error113("Double free: object of type C"); } else { C_nextFree_511[C_firstFree_198] = this_120; C_firstFree_198 = (C_firstFree_198 + 1); C_typeId_319[this_120] = 0; }; }