array test_cs123 integer test_count128 array C_nextFree308 integer C_firstFree136 integer C_maxIndex218 array C_typeId848 array C_alive247 integer test_count128 = 0 integer C_firstFree136 = 0 integer C_maxIndex218 = 0 function initGlobals169() { } function main395() { initGlobals169(); init_test380(); } function config628() { } function init_test380() { local integer i748 local integer j210 test_count_128 = 0; i_748 = 0; loop { exitwhen (i_748 > 1000); if ((test_count_128 < 100) and (GetRandomReal175(0., 1.) <= 0.5)) { test_cs_123[test_count_128] = new_C748(); test_count_128 = (test_count_128 + 1); } else { }; if ((test_count_128 > 0) and (GetRandomReal175(0., 1.) <= 0.1)) { j_210 = GetRandomInt874(0, (test_count_128 - 1)); dispatch_C_destroyC165(test_cs_123[j_210]); test_count_128 = (test_count_128 - 1); test_cs_123[j_210] = test_cs_123[test_count_128]; } else { }; i_748 = (i_748 + 1); }; testSuccess108(); } IS_NATIVE function testFail161(string msg923) { } IS_NATIVE IS_EXTERN @extern function GetRandomReal175(real a953, real b670) returns real { } IS_NATIVE IS_EXTERN @extern function GetRandomInt874(integer a225, integer b157) returns integer { } IS_NATIVE function testSuccess108() { } function new_C748() returns integer { local integer this691 if (C_firstFree_136 == 0) { if (C_maxIndex_218 < 32768) { C_maxIndex_218 = (C_maxIndex_218 + 1); this_691 = C_maxIndex_218; C_typeId_848[this_691] = 1; } else { error163("Out of memory: Could not create C."); this_691 = 0; }; } else { C_firstFree_136 = (C_firstFree_136 - 1); this_691 = C_nextFree_308[C_firstFree_136]; C_typeId_848[this_691] = 1; }; if (C_alive_247[this_691] == 1) { testFail161("already alive"); } else { }; C_alive_247[this_691] = 1; return this_691; } function error163(string msg560) { $debugPrint126((msg_560 + (" " + #getStackTrace()))); } function dispatch_C_destroyC165(integer this162) { if (C_typeId_848[this_162] == 0) { if (this_162 == 0) { error163("Nullpointer exception when calling C.C"); } else { error163("Called C.C on invalid object."); }; } else { }; C_alive_247[this_162] = 2; if (C_typeId_848[this_162] == 0) { error163("Double free: object of type C"); } else { C_nextFree_308[C_firstFree_136] = this_162; C_firstFree_136 = (C_firstFree_136 + 1); C_typeId_848[this_162] = 0; }; }