00001 /* -*-C-*- 00002 ******************************************************************************** 00003 * 00004 * File: structures.h (Formerly structures.h) 00005 * Description: Allocate all the different types of structures. 00006 * Author: Mark Seaman, OCR Technology 00007 * Created: Wed May 30 10:12:12 1990 00008 * Modified: Tue May 21 11:07:47 1991 (Mark Seaman) marks@hpgrlt 00009 * Language: C 00010 * Package: N/A 00011 * Status: Experimental (Do Not Distribute) 00012 * 00013 * (c) Copyright 1990, Hewlett-Packard Company. 00014 ** Licensed under the Apache License, Version 2.0 (the "License"); 00015 ** you may not use this file except in compliance with the License. 00016 ** You may obtain a copy of the License at 00017 ** http://www.apache.org/licenses/LICENSE-2.0 00018 ** Unless required by applicable law or agreed to in writing, software 00019 ** distributed under the License is distributed on an "AS IS" BASIS, 00020 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00021 ** See the License for the specific language governing permissions and 00022 ** limitations under the License. 00023 * 00024 *********************************************************************************/ 00025 #ifndef STRUCTURES_H 00026 #define STRUCTURES_H 00027 00028 /*---------------------------------------------------------------------- 00029 I n c l u d e s 00030 ----------------------------------------------------------------------*/ 00031 #include "tessclas.h" 00032 #include "oldlist.h" 00033 #include "freelist.h" 00034 #include "danerror.h" 00035 00036 #define NUM_DATA_TYPES 20 00037 00038 extern int max_data_types; 00039 extern void_void memory_print_functions[NUM_DATA_TYPES]; 00040 00041 /*---------------------------------------------------------------------- 00042 M a c r o s 00043 ----------------------------------------------------------------------*/ 00044 /********************************************************************** 00045 * makestructure 00046 * 00047 * Allocate a chunk of memory for a particular data type. This macro 00048 * defines an allocation, deallocation, and status printing function 00049 * for each new data type. 00050 **********************************************************************/ 00051 00052 #define makestructure(newfunc,old,print,type,nextfree,blocksize,typestring,usecount) \ 00053 type *newfunc() \ 00054 { \ 00055 return new type; \ 00056 } \ 00057 \ 00058 \ 00059 \ 00060 void old(type* deadelement) \ 00061 { \ 00062 delete deadelement; \ 00063 } \ 00064 00065 00066 /********************************************************************** 00067 * newstructure 00068 * 00069 * Allocate a chunk of memory for a particular data type. 00070 **********************************************************************/ 00071 00072 #define newstructure(name,type,nextfree,blocksize,errorstring,usecount)\ 00073 type *name() /*returns a new type*/\ 00074 {\ 00075 return new type;\ 00076 } 00077 00078 /********************************************************************** 00079 * oldstructure 00080 * 00081 * Returns a structure to the freelist 00082 **********************************************************************/ 00083 00084 #define oldstructure(name,type,nextfree,stringtype,usecount)\ 00085 \ 00086 type *name(type* deadelement)\ 00087 {\ 00088 type *returnelement; /*return next ptr*/\ 00089 \ 00090 returnelement=deadelement->next; /*return link*/\ 00091 delete deadelement; \ 00092 return returnelement;\ 00093 } 00094 00095 /*---------------------------------------------------------------------- 00096 F u n c t i o n s 00097 ----------------------------------------------------------------------*/ 00098 extern TBLOB *newblob(); 00099 extern TBLOB *oldblob(TBLOB *); 00100 00101 extern TESSLINE *newoutline(); 00102 extern void oldoutline(TESSLINE *); 00103 00104 extern EDGEPT *newedgept(); 00105 extern EDGEPT *oldedgept(EDGEPT *); 00106 00107 extern TWERD *newword(); 00108 extern void oldword(TWERD *); 00109 00110 extern LIST new_cell(); 00111 extern void free_cell(LIST); 00112 #endif