void freeResources(Agent agents[], Graph g){ int i; for(i=0;i<=NUM_DETECTIVES;i++){ destroyAgent(agents[i]); } destroyGraph(g); }
OMR_Agent * OMR_Agent::createAgent(OMR_VM *vm, char const *arg) { OMR_Agent *newAgent = NULL; if (NULL != arg) { OMRPORT_ACCESS_FROM_OMRVM(vm); newAgent = (OMR_Agent *)omrmem_allocate_memory(sizeof(*newAgent), OMRMEM_CATEGORY_VM); if (NULL != newAgent) { new(newAgent) OMR_Agent(vm, arg); if (INITIALIZED != newAgent->_state) { destroyAgent(newAgent); newAgent = NULL; } } } return newAgent; }
// destroy the current VASTATE node, reverse the createNode actions void VASTATE::destroyNode () { if (_state != ABSENT) { // destroy agents first, as arbitrators may need to handle certain closeoff tasks if (_agents.size () > 0) destroyAgent (_agents[0]); if (_arbitrators.size () > 0) destroyArbitrator (_arbitrators[0]); _arb_logics.clear (); _agent_logics.clear (); _pass.clear (); _state = ABSENT; } }