• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* -*-C-*-
2  ********************************************************************************
3  *
4  * File:        structures.h  (Formerly structures.h)
5  * Description:  Allocate all the different types of structures.
6  * Author:       Mark Seaman, OCR Technology
7  * Created:      Wed May 30 10:12:12 1990
8  * Modified:     Tue May 21 11:07:47 1991 (Mark Seaman) marks@hpgrlt
9  * Language:     C
10  * Package:      N/A
11  * Status:       Experimental (Do Not Distribute)
12  *
13  * (c) Copyright 1990, Hewlett-Packard Company.
14  ** Licensed under the Apache License, Version 2.0 (the "License");
15  ** you may not use this file except in compliance with the License.
16  ** You may obtain a copy of the License at
17  ** http://www.apache.org/licenses/LICENSE-2.0
18  ** Unless required by applicable law or agreed to in writing, software
19  ** distributed under the License is distributed on an "AS IS" BASIS,
20  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  ** See the License for the specific language governing permissions and
22  ** limitations under the License.
23  *
24  *********************************************************************************/
25 #ifndef STRUCTURES_H
26 #define STRUCTURES_H
27 
28 /*----------------------------------------------------------------------
29               I n c l u d e s
30 ----------------------------------------------------------------------*/
31 #include "tessclas.h"
32 #include "oldlist.h"
33 #include "freelist.h"
34 #include "danerror.h"
35 
36 #define NUM_DATA_TYPES 20
37 
38 extern int max_data_types;
39 extern void_void memory_print_functions[NUM_DATA_TYPES];
40 
41 /*----------------------------------------------------------------------
42               M a c r o s
43 ----------------------------------------------------------------------*/
44 /**********************************************************************
45  * makestructure
46  *
47  * Allocate a chunk of memory for a particular data type.  This macro
48  * defines an allocation, deallocation, and status printing function
49  * for each new data type.
50  **********************************************************************/
51 
52 #define makestructure(newfunc,old,print,type,nextfree,blocksize,typestring,usecount)                \
53 type *newfunc()                                                                  \
54 {                                                                            \
55 	return new type; \
56 }                                                                            \
57 																									\
58 																									\
59 																									\
60 void old(type* deadelement)                                                       \
61 {                                                                            \
62 	delete deadelement; \
63 }                                                                            \
64 
65 
66 /**********************************************************************
67  * newstructure
68  *
69  * Allocate a chunk of memory for a particular data type.
70  **********************************************************************/
71 
72 #define newstructure(name,type,nextfree,blocksize,errorstring,usecount)\
73 type *name()											/*returns a new type*/\
74 {\
75 	return new type;\
76 }
77 
78 /**********************************************************************
79  * oldstructure
80  *
81  * Returns a structure to the freelist
82  **********************************************************************/
83 
84 #define oldstructure(name,type,nextfree,stringtype,usecount)\
85 \
86 type *name(type* deadelement)\
87 {\
88 	type                    *returnelement;				/*return next ptr*/\
89 \
90 	returnelement=deadelement->next;					/*return link*/\
91 	delete deadelement;  \
92 	return returnelement;\
93 }
94 
95 /*----------------------------------------------------------------------
96               F u n c t i o n s
97 ----------------------------------------------------------------------*/
98 extern TBLOB *newblob();
99 extern TBLOB *oldblob(TBLOB *);
100 
101 extern TESSLINE *newoutline();
102 extern void oldoutline(TESSLINE *);
103 
104 extern EDGEPT *newedgept();
105 extern EDGEPT *oldedgept(EDGEPT *);
106 
107 extern TWERD *newword();
108 extern void oldword(TWERD *);
109 
110 extern LIST new_cell();
111 extern void free_cell(LIST);
112 #endif
113