1 | /* |
---|
2 | * TransFig: Facility for Translating Fig code |
---|
3 | * Copyright (c) 1985 Supoj Sutantavibul |
---|
4 | * Copyright (c) 1991 Micah Beck |
---|
5 | * |
---|
6 | * Permission to use, copy, modify, distribute, and sell this software and its |
---|
7 | * documentation for any purpose is hereby granted without fee, provided that |
---|
8 | * the above copyright notice appear in all copies and that both that |
---|
9 | * copyright notice and this permission notice appear in supporting |
---|
10 | * documentation. The authors make no representations about the suitability |
---|
11 | * of this software for any purpose. It is provided "as is" without express |
---|
12 | * or implied warranty. |
---|
13 | * |
---|
14 | * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
---|
15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO |
---|
16 | * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
---|
17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, |
---|
18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
---|
19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
---|
20 | * PERFORMANCE OF THIS SOFTWARE. |
---|
21 | * |
---|
22 | */ |
---|
23 | |
---|
24 | #include <stdio.h> |
---|
25 | #include <math.h> |
---|
26 | #include "object.h" |
---|
27 | |
---|
28 | free_arc(list) |
---|
29 | F_arc **list; |
---|
30 | { |
---|
31 | F_arc *a, *arc; |
---|
32 | |
---|
33 | for (a = *list; a != NULL;) { |
---|
34 | arc = a; |
---|
35 | a = a->next; |
---|
36 | if (arc->for_arrow) free((char*)arc->for_arrow); |
---|
37 | if (arc->back_arrow) free((char*)arc->back_arrow); |
---|
38 | free((char*)arc); |
---|
39 | } |
---|
40 | *list = NULL; |
---|
41 | } |
---|
42 | |
---|
43 | free_compound(list) |
---|
44 | F_compound **list; |
---|
45 | { |
---|
46 | F_compound *c, *compound; |
---|
47 | |
---|
48 | for (c = *list; c != NULL;) { |
---|
49 | compound = c; |
---|
50 | c = c->next; |
---|
51 | free_arc(&compound->arcs); |
---|
52 | free_compound(&compound->compounds); |
---|
53 | free_ellipse(&compound->ellipses); |
---|
54 | free_line(&compound->lines); |
---|
55 | free_spline(&compound->splines); |
---|
56 | free_text(&compound->texts); |
---|
57 | free((char*)compound); |
---|
58 | } |
---|
59 | *list = NULL; |
---|
60 | } |
---|
61 | |
---|
62 | free_ellipse(list) |
---|
63 | F_ellipse **list; |
---|
64 | { |
---|
65 | F_ellipse *e, *ellipse; |
---|
66 | |
---|
67 | for (e = *list; e != NULL;) { |
---|
68 | ellipse = e; |
---|
69 | e = e->next; |
---|
70 | free((char*)ellipse); |
---|
71 | } |
---|
72 | *list = NULL; |
---|
73 | } |
---|
74 | |
---|
75 | free_line(list) |
---|
76 | F_line **list; |
---|
77 | { |
---|
78 | F_line *l, *line; |
---|
79 | |
---|
80 | for (l = *list; l != NULL;) { |
---|
81 | line = l; |
---|
82 | l = l->next; |
---|
83 | free_linestorage(line); |
---|
84 | } |
---|
85 | *list = NULL; |
---|
86 | } |
---|
87 | |
---|
88 | free_text(list) |
---|
89 | F_text **list; |
---|
90 | { |
---|
91 | F_text *t, *text; |
---|
92 | |
---|
93 | for (t = *list; t != NULL;) { |
---|
94 | text = t; |
---|
95 | t = t->next; |
---|
96 | cfree(text->cstring); |
---|
97 | free((char*)text); |
---|
98 | } |
---|
99 | *list = NULL; |
---|
100 | } |
---|
101 | |
---|
102 | free_spline(list) |
---|
103 | F_spline **list; |
---|
104 | { |
---|
105 | F_spline *s, *spline; |
---|
106 | |
---|
107 | for (s = *list; s != NULL;) { |
---|
108 | spline = s; |
---|
109 | s = s->next; |
---|
110 | free_splinestorage(spline); |
---|
111 | } |
---|
112 | *list = NULL; |
---|
113 | } |
---|
114 | |
---|
115 | free_splinestorage(s) |
---|
116 | F_spline *s; |
---|
117 | { |
---|
118 | F_point *p, *q; |
---|
119 | F_control *a, *b; |
---|
120 | |
---|
121 | for (p = s->points; p != NULL; p = q) { |
---|
122 | q = p->next; |
---|
123 | free((char*)p); |
---|
124 | } |
---|
125 | for (a = s->controls; a != NULL; a = b) { |
---|
126 | b = a->next; |
---|
127 | free((char*)a); |
---|
128 | } |
---|
129 | if (s->for_arrow) free((char*)s->for_arrow); |
---|
130 | if (s->back_arrow) free((char*)s->back_arrow); |
---|
131 | free((char*)s); |
---|
132 | } |
---|
133 | |
---|
134 | free_linestorage(l) |
---|
135 | F_line *l; |
---|
136 | { |
---|
137 | F_point *p, *q; |
---|
138 | |
---|
139 | for (p = l->points; p != NULL; p = q) { |
---|
140 | q = p->next; |
---|
141 | free((char*)p); |
---|
142 | } |
---|
143 | if (l->for_arrow) free((char*)l->for_arrow); |
---|
144 | if (l->back_arrow) free((char*)l->back_arrow); |
---|
145 | free((char*)l); |
---|
146 | } |
---|