| iMatix home page
| << | < | > | >>
SMT Logo SMT
Version 2.81

 

agent_destroy

#include "smtlib.h"
int
agent_destroy (
    AGENT *agent                        /*  Agent to destroy; null = all     */
)

Synopsis

Destroys the agent. Returns 0 when completed. The agent argument points to an agent block, or is null. If null, all agents are destroyed. Returns 0 when completed normally, else returns -1 and sets smt_errno to one of these values:
SMT NOTREADY smt_init() was not called, or failed

Source Code - (smtlib.c)

{
#if (defined (SMT_TRACE))
    trace ("agent_destroy: agent=%s", agent? agent-> name: "ALL");
#endif
    if (!smt_alive)                     /*  If SMT API was not correctly     */
      {                                 /*    initialised, forget it         */
        smt_errno = SMT_NOTREADY;
        return (-1);
      }

    if (agent == NULL)                  /*  Destroy all agents if wanted     */
        while (agents.next != &agents)
            agent destroy (agents.next);
    else                                /*  Else destroy this agent          */
      {
        /*   Destroy all queues and methods declared for the agent           */
        while (agent-> queues.next != &agent-> queues)
            queue destroy (agent-> queues.next);
        while (agent-> methods.next != &agent-> methods)
            method destroy (agent-> methods.next);

        /*  We have to be a little careful or sym_delete_symbol () will      */
        /*  try to release the symbol's data area; the data area points      */
        /*  to our node, which we want to release ourselves.                 */
        agent-> symbol-> data = NULL;
        sym_delete_symbol (dict, agent-> symbol);

        /*  Now delete the agent                                             */
        mem_strfree (&agent-> name);    /*  First we take its name           */
        node_destroy (agent);           /*  ... then we take its life        */
      }
    return (0);
}

| << | < | > | >> iMatix Copyright © 1996-99 iMatix Corporation