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

 

semaph_destroy

#include "smtlib.h"
int
semaph_destroy (
    SEMAPH *semaph                      /*  Semaph to destroy; null = all    */
)

Synopsis

Destroys the semaphore. Returns 0 when completed. The semaph argument points to an semaph block, or is null. If null, all semaphores 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 ("semaph_destroy: semaph=%s", semaph? semaph-> name: "ALL");
#endif
    if (!smt_alive)                     /*  If SMT API was not correctly     */
      {                                 /*    initialised, forget it         */
        smt_errno = SMT_NOTREADY;
        return (-1);
      }

    if (semaph == NULL)                 /*  Destroy all semaphs if wanted    */
        while (semaphs.next != &semaphs)
            semaph destroy (semaphs.next);
    else                                /*  Else destroy this semaph         */
      {
        /*  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.                 */
        semaph-> symbol-> data = NULL;
        sym_delete_symbol (dict, semaph-> symbol);

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

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