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