array C_nextFree189 integer C_firstFree166 integer C_maxIndex960 array C_typeId100 array C_i105 integer C_firstFree166 = 0 integer C_maxIndex960 = 0 function initGlobals765() { C_firstFree_166 = 0; C_maxIndex_960 = 0; } function main145() { initGlobals765(); init_test169(); } function config117() { } function init_test169() { dispatch_C_destroyC558(new_C989()); } IS_NATIVE function testSuccess101() { } function C_init277(integer this165) { C_i_105[this_165] = 3; } function new_C989() returns integer { local integer this191 this_191 = alloc_C206(); construct_C631(this_191); return this_191; } function construct_C631(integer this177) { C_init277(this_177); } function C_onDestroy819(integer this709) { C_i_105[this_709] = (C_i_105[this_709] + 1); testSuccess101(); } function destroyC211(integer this626) { C_onDestroy819(this_626); dealloc_C137(this_626); } function alloc_C206() returns integer { local integer this680 if (C_firstFree_166 == 0) { if (C_maxIndex_960 < 32768) { C_maxIndex_960 = (C_maxIndex_960 + 1); this_680 = C_maxIndex_960; C_typeId_100[this_680] = 1; } else { error212("Out of memory: Could not create C."); this_680 = 0; }; } else { C_firstFree_166 = (C_firstFree_166 - 1); this_680 = C_nextFree_189[C_firstFree_166]; C_typeId_100[this_680] = 1; }; return this_680; } function error212(string msg438) { $debugPrint156((msg_438 + (" " + #getStackTrace()))); } function dealloc_C137(integer obj144) { if (C_typeId_100[obj_144] == 0) { error212("Double free: object of type C"); } else { C_nextFree_189[C_firstFree_166] = obj_144; C_firstFree_166 = (C_firstFree_166 + 1); C_typeId_100[obj_144] = 0; }; } function dispatch_C_destroyC558(integer this193) { if (C_typeId_100[this_193] == 0) { if (this_193 == 0) { error212("Nullpointer exception when calling C.C"); } else { error212("Called C.C on invalid object."); }; } else { }; destroyC211(this_193); }