60 #include "allheaders.h" 62 static const l_int32 INITIAL_PTR_ARRAYSIZE = 20;
82 PROCNAME(
"lstackCreate");
85 nalloc = INITIAL_PTR_ARRAYSIZE;
88 lstack->
array = (
void **)LEPT_CALLOC(nalloc,
sizeof(
void *));
91 return (
L_STACK *)ERROR_PTR(
"lstack array not made", procName, NULL);
127 PROCNAME(
"lstackDestroy");
129 if (plstack == NULL) {
130 L_WARNING(
"ptr address is NULL\n", procName);
133 if ((lstack = *plstack) == NULL)
137 while(lstack->
n > 0) {
141 }
else if (lstack->
n > 0) {
142 L_WARNING(
"memory leak of %d items in lstack\n", procName, lstack->
n);
149 LEPT_FREE(lstack->
array);
170 PROCNAME(
"lstackAdd");
173 return ERROR_INT(
"lstack not defined", procName, 1);
175 return ERROR_INT(
"item not defined", procName, 1);
178 if (lstack->
n >= lstack->
nalloc)
182 lstack->
array[lstack->
n] = (
void *)item;
201 PROCNAME(
"lstackRemove");
204 return ERROR_PTR(
"lstack not defined", procName, NULL);
210 item = lstack->
array[lstack->
n];
225 PROCNAME(
"lstackExtendArray");
228 return ERROR_INT(
"lstack not defined", procName, 1);
231 sizeof(
void *) * lstack->
nalloc,
232 2 *
sizeof(
void *) * lstack->
nalloc)) == NULL)
233 return ERROR_INT(
"new lstack array not defined", procName, 1);
249 PROCNAME(
"lstackGetCount");
252 return ERROR_INT(
"lstack not defined", procName, 1);
275 PROCNAME(
"lstackPrint");
278 return ERROR_INT(
"stream not defined", procName, 1);
280 return ERROR_INT(
"lstack not defined", procName, 1);
282 fprintf(fp,
"\n Stack: nalloc = %d, n = %d, array = %p\n",
284 for (i = 0; i < lstack->
n; i++)
285 fprintf(fp,
"array[%d] = %p\n", i, lstack->
array[i]);
void lstackDestroy(L_STACK **plstack, l_int32 freeflag)
lstackDestroy()
l_int32 lstackGetCount(L_STACK *lstack)
lstackGetCount()
l_ok lstackPrint(FILE *fp, L_STACK *lstack)
lstackPrint()
void * reallocNew(void **pindata, l_int32 oldsize, l_int32 newsize)
reallocNew()
l_ok lstackAdd(L_STACK *lstack, void *item)
lstackAdd()
void * lstackRemove(L_STACK *lstack)
lstackRemove()
L_STACK * lstackCreate(l_int32 nalloc)
lstackCreate()
struct L_Stack * auxstack
static l_int32 lstackExtendArray(L_STACK *lstack)
lstackExtendArray()