array test_cs210 integer test_count211 array C_nextFree192 integer C_firstFree564 integer C_maxIndex180 array C_typeId657 array C_alive417 integer test_count211 = 0 integer C_firstFree564 = 0 integer C_maxIndex180 = 0 function initGlobals209() { } function main114() { initGlobals209(); init_test158(); } function config188() { } function init_test158() { local integer i735 local integer j207 test_count_211 = 0; i_735 = 0; loop { exitwhen (i_735 > 1000); if ((test_count_211 < 100) and (GetRandomReal173(0., 1.) <= 0.5)) { test_cs_210[test_count_211] = new_C965(); test_count_211 = (test_count_211 + 1); } else { }; if ((test_count_211 > 0) and (GetRandomReal173(0., 1.) <= 0.1)) { j_207 = GetRandomInt471(0, (test_count_211 - 1)); dispatch_C_destroyC158(test_cs_210[j_207]); test_count_211 = (test_count_211 - 1); test_cs_210[j_207] = test_cs_210[test_count_211]; } else { }; i_735 = (i_735 + 1); }; testSuccess137(); } IS_NATIVE function testFail696(string msg175) { } IS_NATIVE IS_EXTERN @extern function GetRandomReal173(real a565, real b196) returns real { } IS_NATIVE IS_EXTERN @extern function GetRandomInt471(integer a949, integer b135) returns integer { } IS_NATIVE function testSuccess137() { } function new_C965() returns integer { local integer this241 local integer this579 local integer this175 if (C_firstFree_564 == 0) { if (C_maxIndex_180 < 32768) { C_maxIndex_180 = (C_maxIndex_180 + 1); this_579 = C_maxIndex_180; C_typeId_657[this_579] = 1; } else { error205("Out of memory: Could not create C."); this_579 = 0; }; } else { C_firstFree_564 = (C_firstFree_564 - 1); this_579 = C_nextFree_192[C_firstFree_564]; C_typeId_657[this_579] = 1; }; this_241 = this_579; this_175 = this_241; if (C_alive_417[this_175] == 1) { testFail696("already alive"); } else { }; C_alive_417[this_175] = 1; return this_241; } function error205(string msg100) { $debugPrint165((msg_100 + (" " + #getStackTrace()))); } function dispatch_C_destroyC158(integer this147) { local integer this416 local integer this101 local integer obj493 if (C_typeId_657[this_147] == 0) { if (this_147 == 0) { error205("Nullpointer exception when calling C.C"); } else { error205("Called C.C on invalid object."); }; } else { }; this_416 = this_147; this_101 = this_416; C_alive_417[this_101] = 2; obj_493 = this_416; if (C_typeId_657[obj_493] == 0) { error205("Double free: object of type C"); } else { C_nextFree_192[C_firstFree_564] = obj_493; C_firstFree_564 = (C_firstFree_564 + 1); C_typeId_657[obj_493] = 0; }; }