1: /*
   2:  * Copyright (c) 1987 by Ed James, UC Berkeley.  All rights reserved.
   3:  *
   4:  * Copy permission is hereby granted provided that this notice is
   5:  * retained on all partial or complete copies.
   6:  *
   7:  * For more info on this and all of my stuff, mail edjames@berkeley.edu.
   8:  */
   9: 
  10: #include "include.h"
  11: 
  12: PLANE   *
  13: newplane()
  14: {
  15:     return ((PLANE *) calloc(1, sizeof (PLANE)));
  16: }
  17: 
  18: append(l, p)
  19:     LIST    *l;
  20:     PLANE   *p;
  21: {
  22:     PLANE   *q = NULL, *r = NULL;
  23: 
  24:     if (l->head == NULL) {
  25:         p->next = p->prev = NULL;
  26:         l->head = l->tail = p;
  27:     } else {
  28:         q = l -> head;
  29: 
  30:         while (q != NULL && q->plane_no < p->plane_no) {
  31:             r = q;
  32:             q = q -> next;
  33:         }
  34: 
  35:         if (q) {
  36:             if (r) {
  37:                 p->prev = r;
  38:                 r->next = p;
  39:                 p->next = q;
  40:                 q->prev = p;
  41:             } else {
  42:                 p->next = q;
  43:                 p->prev = NULL;
  44:                 q->prev = p;
  45:                 l->head = p;
  46:             }
  47:         } else {
  48:             l->tail->next = p;
  49:             p->next = NULL;
  50:             p->prev = l->tail;
  51:             l->tail = p;
  52:         }
  53:     }
  54: }
  55: 
  56: delete(l, p)
  57:     LIST    *l;
  58:     PLANE   *p;
  59: {
  60:     if (l->head == NULL)
  61:         loser(p, "deleted a non-existant plane! Get help!");
  62: 
  63:     if (l->head == p && l->tail == p)
  64:         l->head = l->tail = NULL;
  65:     else if (l->head == p) {
  66:         l->head = p->next;
  67:         l->head->prev = NULL;
  68:     } else if (l->tail == p) {
  69:         l->tail = p->prev;
  70:         l->tail->next = NULL;
  71:     } else {
  72:         p->prev->next = p->next;
  73:         p->next->prev = p->prev;
  74:     }
  75: }

Defined functions

append defined in line 18; used 3 times
delete defined in line 56; used 2 times
newplane defined in line 12; used 2 times
Last modified: 1987-03-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1235
Valid CSS Valid XHTML 1.0 Strict