1: /* $Header$ */
   2: 
   3: /*
   4:  * Author: Peter J. Nicklin
   5:  */
   6: 
   7: /*
   8:  * slsrm() removes all instances of key+string from list slslist.
   9:  * If key is null the entire list is removed.
  10:  */
  11: #include "macro.h"
  12: #include "null.h"
  13: #include "slslist.h"
  14: 
  15: void
  16: slsrm(key, slslist)
  17:     char *key;          /* key string */
  18:     SLSLIST *slslist;       /* pointer to list head block */
  19: {
  20:     SLSBLK *curblk;         /* current list block */
  21:     SLSBLK *nxtblk;         /* next list block */
  22:     SLSBLK *prvblk;         /* previous list block */
  23: 
  24:     if (key == NULL)
  25:         {
  26:         while (slslist->head != NULL)
  27:             {
  28:             nxtblk = slslist->head->next;
  29:             free(slslist->head->key);
  30:             free(slslist->head->string);
  31:             free((char *) slslist->head);
  32:             slslist->head = nxtblk;
  33:             }
  34:         free((char *) slslist);
  35:         }
  36:     else    {
  37:         /* first block is a special case */
  38:         while (slslist->head != NULL)
  39:             {
  40:             if (!EQUAL(slslist->head->key, key))
  41:                 break;
  42:             nxtblk = slslist->head->next;
  43:             free(slslist->head->key);
  44:             free(slslist->head->string);
  45:             free((char *) slslist->head);
  46:             slslist->head = nxtblk;
  47:             slslist->nk--;
  48:             }
  49:         if (slslist->head == NULL)
  50:             slslist->tail = NULL;
  51: 
  52:         /* remainder of list */
  53:         if (slslist->head != NULL)
  54:             {
  55:             prvblk = slslist->head;
  56:             curblk = slslist->head->next;
  57:             while (curblk != NULL)
  58:                 if (EQUAL(curblk->key, key))
  59:                     {
  60:                     if (curblk == slslist->tail)
  61:                         slslist->tail = prvblk;
  62:                     prvblk->next = curblk->next;
  63:                     free(curblk->key);
  64:                     free(curblk->string);
  65:                     free((char *) curblk);
  66:                     curblk = prvblk->next;
  67:                     slslist->nk--;
  68:                     }
  69:                 else    {
  70:                     prvblk = curblk;
  71:                     curblk = curblk->next;
  72:                     }
  73:             }
  74:         }
  75: }

Defined functions

slsrm defined in line 15; never used
Last modified: 1985-07-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 678
Valid CSS Valid XHTML 1.0 Strict