60 #include <config_auto.h>
63 #include "allheaders.h"
66 static const l_uint32 MaxPtrArraySize = 100000;
86 if (n <= 0 || n > MaxPtrArraySize)
90 lstack->
array = (
void **)LEPT_CALLOC(n,
sizeof(
void *));
93 return (
L_STACK *)ERROR_PTR(
"lstack array not made", __func__, NULL);
128 if (plstack == NULL) {
129 L_WARNING(
"ptr address is NULL\n", __func__);
132 if ((lstack = *plstack) == NULL)
136 while(lstack->
n > 0) {
140 }
else if (lstack->
n > 0) {
141 L_WARNING(
"memory leak of %d items in lstack\n", __func__, lstack->
n);
148 LEPT_FREE(lstack->
array);
170 return ERROR_INT(
"lstack not defined", __func__, 1);
172 return ERROR_INT(
"item not defined", __func__, 1);
175 if (lstack->
n >= lstack->
nalloc) {
177 return ERROR_INT(
"extension failed", __func__, 1);
181 lstack->
array[lstack->
n] = (
void *)item;
201 return ERROR_PTR(
"lstack not defined", __func__, NULL);
207 item = lstack->
array[lstack->
n];
223 return ERROR_INT(
"lstack not defined", __func__, 1);
226 sizeof(
void *) * lstack->
nalloc,
227 2 *
sizeof(
void *) * lstack->
nalloc)) == NULL)
228 return ERROR_INT(
"new lstack array not defined", __func__, 1);
245 return ERROR_INT(
"lstack not defined", __func__, 1);
269 return ERROR_INT(
"stream not defined", __func__, 1);
271 return ERROR_INT(
"lstack not defined", __func__, 1);
273 fprintf(fp,
"\n Stack: nalloc = %d, n = %d, array = %p\n",
275 for (i = 0; i < lstack->
n; i++)
276 fprintf(fp,
"array[%d] = %p\n", i, lstack->
array[i]);
l_int32 lstackGetCount(L_STACK *lstack)
lstackGetCount()
static const l_int32 InitialPtrArraySize
static l_int32 lstackExtendArray(L_STACK *lstack)
lstackExtendArray()
void lstackDestroy(L_STACK **plstack, l_int32 freeflag)
lstackDestroy()
l_ok lstackAdd(L_STACK *lstack, void *item)
lstackAdd()
void * lstackRemove(L_STACK *lstack)
lstackRemove()
L_STACK * lstackCreate(l_int32 n)
lstackCreate()
l_ok lstackPrint(FILE *fp, L_STACK *lstack)
lstackPrint()
struct L_Stack * auxstack
void * reallocNew(void **pindata, size_t oldsize, size_t newsize)
reallocNew()