Leptonica 1.68
C Image Processing Library
|
00001 /*====================================================================* 00002 - Copyright (C) 2001 Leptonica. All rights reserved. 00003 - This software is distributed in the hope that it will be 00004 - useful, but with NO WARRANTY OF ANY KIND. 00005 - No author or distributor accepts responsibility to anyone for the 00006 - consequences of using this software, or for whether it serves any 00007 - particular purpose or works at all, unless he or she says so in 00008 - writing. Everyone is granted permission to copy, modify and 00009 - redistribute this source code, for commercial or non-commercial 00010 - purposes, with the following restrictions: (1) the origin of this 00011 - source code must not be misrepresented; (2) modified versions must 00012 - be plainly marked as such; and (3) this notice may not be removed 00013 - or altered from any source or modified source distribution. 00014 *====================================================================*/ 00015 00016 #ifndef LEPTONICA_STACK_H 00017 #define LEPTONICA_STACK_H 00018 00019 /* 00020 * stack.h 00021 * 00022 * Expandable pointer stack for arbitrary void* data. 00023 * 00024 * The L_Stack is an array of void * ptrs, onto which arbitrary 00025 * objects can be stored. At any time, the number of 00026 * stored objects is stack->n. The object at the bottom 00027 * of the stack is at array[0]; the object at the top of 00028 * the stack is at array[n-1]. New objects are added 00029 * to the top of the stack, at the first available location, 00030 * which is array[n]. Objects are removed from the top of the 00031 * stack. When an attempt is made to remove an object from an 00032 * empty stack, the result is null. When the stack becomes 00033 * filled, so that n = nalloc, the size is doubled. 00034 * 00035 * The auxiliary stack can be used to store and remove 00036 * objects for re-use. It must be created by a separate 00037 * call to pstackCreate(). [Just imagine the chaos if 00038 * pstackCreate() created the auxiliary stack!] 00039 * pstackDestroy() checks for the auxiliary stack and removes it. 00040 */ 00041 00042 00043 /* Note that array[n] is the first null ptr in the array */ 00044 struct L_Stack 00045 { 00046 l_int32 nalloc; /* size of ptr array */ 00047 l_int32 n; /* number of stored elements */ 00048 void **array; /* ptr array */ 00049 struct L_Stack *auxstack; /* auxiliary stack */ 00050 }; 00051 typedef struct L_Stack L_STACK; 00052 00053 00054 #endif /* LEPTONICA_STACK_H */ 00055