string test_s143 array C_nextFree744 integer C_firstFree963 integer C_maxIndex157 array C_typeId448 string test_s143 = "" integer C_firstFree963 = 0 integer C_maxIndex157 = 0 function initGlobals184() { } function main174() { initGlobals184(); init_test137(); } function config118() { } function init_test137() { local integer c134 local integer this378 test_s_143 = ""; c_134 = new_C580(); this_378 = c_134; if (C_typeId_448[this_378] == 0) { if (this_378 == 0) { error115("Nullpointer exception when calling C.C"); } else { error115("Called C.C on invalid object."); }; } else { }; destroyC132(this_378); if (test_s_143 != "ABCcba") { testFail155(("fail, result = " + test_s_143)); } else { }; testSuccess210(); } IS_NATIVE function testFail155(string msg112) { } IS_NATIVE function testSuccess210() { } function new_C580() returns integer { local integer this214 local integer this148 local integer this758 local string x366 local string x900 if (C_firstFree_963 == 0) { if (C_maxIndex_157 < 32768) { C_maxIndex_157 = (C_maxIndex_157 + 1); this_148 = C_maxIndex_157; C_typeId_448[this_148] = 1; } else { error115("Out of memory: Could not create C."); this_148 = 0; }; } else { C_firstFree_963 = (C_firstFree_963 - 1); this_148 = C_nextFree_744[C_firstFree_963]; C_typeId_448[this_148] = 1; }; this_214 = this_148; this_758 = this_214; x_900 = "A"; test_s_143 = (test_s_143 + x_900); x_366 = "B"; test_s_143 = (test_s_143 + x_366); test_s_143 = (test_s_143 + "C"); return this_214; } function destroyC132(integer this167) { local integer obj124 test_s_143 = (test_s_143 + "c"); test_s_143 = (test_s_143 + "b"); test_s_143 = (test_s_143 + "a"); obj_124 = this_167; if (C_typeId_448[obj_124] == 0) { error115("Double free: object of type C"); } else { C_nextFree_744[C_firstFree_963] = obj_124; C_firstFree_963 = (C_firstFree_963 + 1); C_typeId_448[obj_124] = 0; }; } function error115(string msg120) { $debugPrint523((msg_120 + (" " + #getStackTrace()))); }