1 /**************************************************************************
2 * Revision 5.1 89/07/27 11:46:53 11:46:53 ray ()
3 * (C) Copyright 1989, Hewlett-Packard Ltd.
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 ** http://www.apache.org/licenses/LICENSE-2.0
8 ** Unless required by applicable law or agreed to in writing, software
9 ** distributed under the License is distributed on an "AS IS" BASIS,
10 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 ** See the License for the specific language governing permissions and
12 ** limitations under the License.
13 *
14 **************************************************************************/
15 #include "mfcpch.h"
16 #include "expandblob.h"
17 #include "tessclas.h"
18 #include "const.h"
19 #include "structures.h"
20 #include "freelist.h"
21
22 /***********************************************************************
23 free_blob(blob) frees the blob and everything it is connected to,
24 i.e. outlines, nodes, edgepts, bytevecs, ratings etc
25 *************************************************************************/
free_blob(register TBLOB * blob)26 void free_blob( /*blob to free */
27 register TBLOB *blob) {
28 if (blob == NULL)
29 return; /*duff blob */
30 free_tree (blob->outlines); /*do the tree of outlines */
31 oldblob(blob); /*free the actual blob */
32 }
33
34
35 /***************************************************************************
36 free_tree(outline) frees the current outline
37 and then its sub-tree
38 *****************************************************************************/
free_tree(register TESSLINE * outline)39 void free_tree( /*outline to draw */
40 register TESSLINE *outline) {
41 if (outline == NULL)
42 return; /*duff outline */
43 if (outline->next != NULL)
44 free_tree (outline->next);
45 if (outline->child != NULL)
46 free_tree (outline->child); /*and sub-tree */
47 free_outline(outline); /*free the outline */
48 }
49
50
51 /*******************************************************************************
52 free_outline(outline) frees an outline and anything connected to it
53 *********************************************************************************/
free_outline(register TESSLINE * outline)54 void free_outline( /*outline to free */
55 register TESSLINE *outline) {
56 if (outline->compactloop != NULL)
57 /*no compact loop */
58 memfree (outline->compactloop);
59
60 if (outline->loop != NULL)
61 free_loop (outline->loop);
62
63 oldoutline(outline);
64 }
65
66
67 /*********************************************************************************
68 free_loop(startpt) frees all the elements of the closed loop
69 starting at startpt
70 ***********************************************************************************/
free_loop(register EDGEPT * startpt)71 void free_loop( /*outline to free */
72 register EDGEPT *startpt) {
73 register EDGEPT *edgept; /*current point */
74
75 if (startpt == NULL)
76 return;
77 edgept = startpt;
78 do {
79 edgept = oldedgept (edgept); /*free it and move on */
80 }
81 while (edgept != startpt);
82 }
83