home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume19 / xfig / part03 / u_free.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-27  |  3.7 KB  |  195 lines

  1. /*
  2.  * FIG : Facility for Interactive Generation of figures
  3.  * Copyright (c) 1985 by Supoj Sutanthavibul
  4.  *
  5.  * "Permission to use, copy, modify, distribute, and sell this software and its
  6.  * documentation for any purpose is hereby granted without fee, provided that
  7.  * the above copyright notice appear in all copies and that both the copyright
  8.  * notice and this permission notice appear in supporting documentation. 
  9.  * No representations are made about the suitability of this software for 
  10.  * any purpose.  It is provided "as is" without express or implied warranty."
  11.  */
  12.  
  13. #include "fig.h"
  14. #include "resources.h"
  15. #include "object.h"
  16.  
  17. free_arc(list)
  18.     F_arc      **list;
  19. {
  20.     F_arc       *a, *arc;
  21.  
  22.     for (a = *list; a != NULL;) {
  23.     arc = a;
  24.     a = a->next;
  25.     if (arc->for_arrow)
  26.         free((char *) arc->for_arrow);
  27.     if (arc->back_arrow)
  28.         free((char *) arc->back_arrow);
  29.     free((char *) arc);
  30.     }
  31.     *list = NULL;
  32. }
  33.  
  34. free_compound(list)
  35.     F_compound      **list;
  36. {
  37.     F_compound       *c, *compound;
  38.  
  39.     for (c = *list; c != NULL;) {
  40.     compound = c;
  41.     c = c->next;
  42.     free_arc(&compound->arcs);
  43.     free_compound(&compound->compounds);
  44.     free_ellipse(&compound->ellipses);
  45.     free_line(&compound->lines);
  46.     free_spline(&compound->splines);
  47.     free_text(&compound->texts);
  48.     free((char *) compound);
  49.     }
  50.     *list = NULL;
  51. }
  52.  
  53. free_ellipse(list)
  54.     F_ellipse      **list;
  55. {
  56.     F_ellipse       *e, *ellipse;
  57.  
  58.     for (e = *list; e != NULL;) {
  59.     ellipse = e;
  60.     e = e->next;
  61.     free((char *) ellipse);
  62.     }
  63.     *list = NULL;
  64. }
  65.  
  66. free_line(list)
  67.     F_line      **list;
  68. {
  69.     F_line       *l, *line;
  70.  
  71.     for (l = *list; l != NULL;) {
  72.     line = l;
  73.     l = l->next;
  74.     free_linestorage(line);
  75.     }
  76.     *list = NULL;
  77. }
  78.  
  79. free_text(list)
  80.     F_text      **list;
  81. {
  82.     F_text       *t, *text;
  83.  
  84.     for (t = *list; t != NULL;) {
  85.     text = t;
  86.     t = t->next;
  87.     free(text->cstring);
  88.     free((char *) text);
  89.     }
  90.     *list = NULL;
  91. }
  92.  
  93. free_spline(list)
  94.     F_spline      **list;
  95. {
  96.     F_spline       *s, *spline;
  97.  
  98.     for (s = *list; s != NULL;) {
  99.     spline = s;
  100.     s = s->next;
  101.     free_splinestorage(spline);
  102.     }
  103.     *list = NULL;
  104. }
  105.  
  106. free_splinestorage(s)
  107.     F_spline       *s;
  108. {
  109.     F_control       *a, *b;
  110.  
  111.     free_points(s->points);
  112.     for (a = s->controls; a != NULL; a = b) {
  113.     b = a->next;
  114.     free((char *) a);
  115.     }
  116.     if (s->for_arrow)
  117.     free((char *) s->for_arrow);
  118.     if (s->back_arrow)
  119.     free((char *) s->back_arrow);
  120.     free((char *) s);
  121. }
  122.  
  123. free_linestorage(l)
  124.     F_line       *l;
  125. {
  126.     free_points(l->points);
  127.     if (l->for_arrow)
  128.     free((char *) l->for_arrow);
  129.     if (l->back_arrow)
  130.     free((char *) l->back_arrow);
  131.     if (l->eps) {
  132.     if (l->eps->bitmap)
  133.         free((char *) l->eps->bitmap);
  134.     if (l->eps->pixmap != 0)
  135.         XFreePixmap(tool_d, l->eps->pixmap);
  136.     free((char *) l->eps);
  137.     }
  138.     free((char *) l);
  139. }
  140.  
  141. free_points(first_point)
  142.     F_point       *first_point;
  143. {
  144.     F_point       *p, *q;
  145.  
  146.     for (p = first_point; p != NULL; p = q) {
  147.     q = p->next;
  148.     free((char *) p);
  149.     }
  150. }
  151.  
  152. free_linkinfo(list)
  153.     F_linkinfo      **list;
  154. {
  155.     F_linkinfo       *l, *link;
  156.  
  157.     for (l = *list; l != NULL;) {
  158.     link = l;
  159.     l = l->next;
  160.     free((char *) link);
  161.     }
  162.     *list = NULL;
  163. }
  164.  
  165. /* free up all the GC's before leaving xfig */
  166.  
  167. free_GCs()
  168.     {
  169.     int i;
  170.  
  171.     XFreeGC(tool_d, gc);
  172.     XFreeGC(tool_d, bold_gc);
  173.     XFreeGC(tool_d, button_gc);
  174.     XFreeGC(tool_d, color_gc);
  175.     XFreeGC(tool_d, ind_button_gc);
  176.     XFreeGC(tool_d, ind_blank_gc);
  177.     XFreeGC(tool_d, blank_gc);
  178.     XFreeGC(tool_d, mouse_blank_gc);
  179.     XFreeGC(tool_d, mouse_button_gc);
  180.     XFreeGC(tool_d, tr_gc);
  181.     XFreeGC(tool_d, tr_erase_gc);
  182.     XFreeGC(tool_d, tr_xor_gc);
  183.     XFreeGC(tool_d, sr_gc);
  184.     XFreeGC(tool_d, sr_erase_gc);
  185.     XFreeGC(tool_d, sr_xor_gc);
  186.  
  187.     for (i=0; i<NUMOPS; i++) {
  188.         XFreeGC(tool_d, gccache[i]);
  189.     }
  190.     for (i=0; i<NUMFILLPATS; i++) {
  191.         XFreeGC(tool_d, fill_gc[i]);
  192.         XFreeGC(tool_d, un_fill_gc[i]);
  193.     }
  194. }
  195.