60 #include <config_auto.h> 63 #include "allheaders.h" 66 static const l_uint32 MaxPtrArraySize = 100000;
86 PROCNAME(
"lstackCreate");
88 if (n <= 0 || n > MaxPtrArraySize)
92 lstack->
array = (
void **)LEPT_CALLOC(n,
sizeof(
void *));
95 return (
L_STACK *)ERROR_PTR(
"lstack array not made", procName, NULL);
130 PROCNAME(
"lstackDestroy");
132 if (plstack == NULL) {
133 L_WARNING(
"ptr address is NULL\n", procName);
136 if ((lstack = *plstack) == NULL)
140 while(lstack->
n > 0) {
144 }
else if (lstack->
n > 0) {
145 L_WARNING(
"memory leak of %d items in lstack\n", procName, lstack->
n);
152 LEPT_FREE(lstack->
array);
173 PROCNAME(
"lstackAdd");
176 return ERROR_INT(
"lstack not defined", procName, 1);
178 return ERROR_INT(
"item not defined", procName, 1);
181 if (lstack->
n >= lstack->
nalloc) {
183 return ERROR_INT(
"extension failed", procName, 1);
187 lstack->
array[lstack->
n] = (
void *)item;
206 PROCNAME(
"lstackRemove");
209 return ERROR_PTR(
"lstack not defined", procName, NULL);
215 item = lstack->
array[lstack->
n];
230 PROCNAME(
"lstackExtendArray");
233 return ERROR_INT(
"lstack not defined", procName, 1);
236 sizeof(
void *) * lstack->
nalloc,
237 2 *
sizeof(
void *) * lstack->
nalloc)) == NULL)
238 return ERROR_INT(
"new lstack array not defined", procName, 1);
254 PROCNAME(
"lstackGetCount");
257 return ERROR_INT(
"lstack not defined", procName, 1);
280 PROCNAME(
"lstackPrint");
283 return ERROR_INT(
"stream not defined", procName, 1);
285 return ERROR_INT(
"lstack not defined", procName, 1);
287 fprintf(fp,
"\n Stack: nalloc = %d, n = %d, array = %p\n",
289 for (i = 0; i < lstack->
n; i++)
290 fprintf(fp,
"array[%d] = %p\n", i, lstack->
array[i]);
void lstackDestroy(L_STACK **plstack, l_int32 freeflag)
lstackDestroy()
static const l_int32 InitialPtrArraySize
l_int32 lstackGetCount(L_STACK *lstack)
lstackGetCount()
l_ok lstackPrint(FILE *fp, L_STACK *lstack)
lstackPrint()
l_ok lstackAdd(L_STACK *lstack, void *item)
lstackAdd()
void * lstackRemove(L_STACK *lstack)
lstackRemove()
L_STACK * lstackCreate(l_int32 n)
lstackCreate()
void * reallocNew(void **pindata, size_t oldsize, size_t newsize)
reallocNew()
struct L_Stack * auxstack
static l_int32 lstackExtendArray(L_STACK *lstack)
lstackExtendArray()