/* Copyright Per Bothner 1987. Read the file Q-INFO */
typedef struct SimpleLink *Link;
struct SimpleLink { Link next; };

#define _AddLink(el, ptr) (el->next = *ptr, *ptr = el)
#define AddLink(el, ptr) _AddLink( (Link)el, (Link*)ptr)
#define _FreeLink(el, ptr) *ptr = el->next
#define FreeLink(el, ptr) _FreeLink((Link)el, (Link*)ptr)

struct SimpleListHdr
  {
    Link first;
    Link *last;
  };

struct SimpleStack
  {
    Link first;
  };

#define InitListHead(hdr) hdr->first = NULL; hdr->last = &hdr->first;

#define _AddFirst(el, hdr) AddLink(el, &hdr->first)
#define AddFirst(el, hdr) if (hdr->first == NULL) AddLast(el, hdr); else _AddFirst(el, hdr->last);
#define AddLast(el, hdr) AddLink(el, hdr->last)


FreeSimpleList(ptr)
    struct Pait ptr;
  {
    for ( ; ptr; ptr = next)
      {
	next = ptr->next;
	FreePair(ptr);
      }
  }
Cons(result, el, hdr)
