home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume8 / xfig2.8 / part02 / free.c < prev    next >
C/C++ Source or Header  |  1990-07-02  |  2KB  |  131 lines

  1. /* 
  2.  *    FIG : Facility for Interactive Generation of figures
  3.  *
  4.  *    Copyright (c) 1988 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
  5.  *    Febuary 1988.
  6.  *
  7.  *    %W%    %G%
  8. */
  9. #include "fig.h"
  10. #include "object.h"
  11.  
  12. free_arc(list)
  13. F_arc    **list;
  14. {
  15.     F_arc    *a, *arc;
  16.  
  17.     for (a = *list; a != NULL;) {
  18.         arc = a;
  19.         a = a->next;
  20.         if (arc->for_arrow) free((char*)arc->for_arrow);
  21.         if (arc->back_arrow) free((char*)arc->back_arrow);
  22.         free((char*)arc);
  23.         } 
  24.     *list = NULL;
  25.     }
  26.  
  27. free_compound(list)
  28. F_compound    **list;
  29. {
  30.     F_compound    *c, *compound;
  31.  
  32.     for (c = *list; c != NULL;) {
  33.         compound = c;
  34.         c = c->next;
  35.         free_arc(&compound->arcs);
  36.         free_compound(&compound->compounds);
  37.         free_ellipse(&compound->ellipses);
  38.         free_line(&compound->lines);
  39.         free_spline(&compound->splines);
  40.         free_text(&compound->texts);
  41.         free((char*)compound);
  42.         } 
  43.     *list = NULL;
  44.     }
  45.  
  46. free_ellipse(list)
  47. F_ellipse    **list;
  48. {
  49.     F_ellipse    *e, *ellipse;
  50.  
  51.     for (e = *list; e != NULL;) {
  52.         ellipse = e;
  53.         e = e->next;
  54.         free((char*)ellipse);
  55.         } 
  56.     *list = NULL;
  57.     }
  58.  
  59. free_line(list)
  60. F_line    **list;
  61. {
  62.     F_line    *l, *line;
  63.  
  64.     for (l = *list; l != NULL;) {
  65.         line = l;
  66.         l = l->next;
  67.         free_linestorage(line);
  68.         } 
  69.     *list = NULL;
  70.     }
  71.  
  72. free_text(list)
  73. F_text    **list;
  74. {
  75.     F_text    *t, *text;
  76.  
  77.     for (t = *list; t != NULL;) {
  78.         text = t;
  79.         t = t->next;
  80.         cfree(text->cstring);
  81.         free((char*)text);
  82.         } 
  83.     *list = NULL;
  84.     }
  85.  
  86. free_spline(list)
  87. F_spline    **list;
  88. {
  89.     F_spline    *s, *spline;
  90.  
  91.     for (s = *list; s != NULL;) {
  92.         spline = s;
  93.         s = s->next;
  94.         free_splinestorage(spline);
  95.         }
  96.     *list = NULL;
  97.     }
  98.  
  99. free_splinestorage(s)
  100. F_spline      *s;
  101. {
  102.         F_point        *p, *q;
  103.         F_control    *a, *b;
  104.  
  105.         for (p = s->points; p != NULL; p = q) {
  106.             q = p->next;
  107.             free((char*)p);
  108.             }
  109.         for (a = s->controls; a != NULL; a = b) {
  110.             b = a->next;
  111.             free((char*)a);
  112.             }
  113.     if (s->for_arrow) free((char*)s->for_arrow);
  114.     if (s->back_arrow) free((char*)s->back_arrow);
  115.         free((char*)s);
  116.         }
  117.  
  118. free_linestorage(l)
  119. F_line    *l;
  120. {
  121.     F_point    *p, *q;
  122.  
  123.     for (p = l->points; p != NULL; p = q) {
  124.         q = p->next;
  125.         free((char*)p);
  126.         }
  127.     if (l->for_arrow) free((char*)l->for_arrow);
  128.     if (l->back_arrow) free((char*)l->back_arrow);
  129.     free((char*)l);
  130.     }
  131.