66 #include <config_auto.h>
70 #include "allheaders.h"
72 static const l_int32 MIN_BUFFER_SIZE = 20;
73 static const l_int32 INITIAL_BUFFER_ARRAYSIZE = 1024;
97 PROCNAME(
"lqueueCreate");
99 if (nalloc < MIN_BUFFER_SIZE)
100 nalloc = INITIAL_BUFFER_ARRAYSIZE;
103 if ((lq->
array = (
void **)LEPT_CALLOC(nalloc,
sizeof(
void *))) == NULL) {
105 return (
L_QUEUE *)ERROR_PTR(
"ptr array not made", procName, NULL);
140 PROCNAME(
"lqueueDestroy");
143 L_WARNING(
"ptr address is NULL\n", procName);
146 if ((lq = *plq) == NULL)
150 while(lq->
nelem > 0) {
154 }
else if (lq->
nelem > 0) {
155 L_WARNING(
"memory leak of %d items in lqueue!\n", procName, lq->
nelem);
159 LEPT_FREE(lq->
array);
191 PROCNAME(
"lqueueAdd");
194 return ERROR_INT(
"lq not defined", procName, 1);
196 return ERROR_INT(
"item not defined", procName, 1);
208 return ERROR_INT(
"extension failed", procName, 1);
228 PROCNAME(
"lqueueExtendArray");
231 return ERROR_INT(
"lq not defined", procName, 1);
234 sizeof(
void *) * lq->
nalloc,
235 2 *
sizeof(
void *) * lq->
nalloc)) == NULL)
236 return ERROR_INT(
"new ptr array not returned", procName, 1);
261 PROCNAME(
"lqueueRemove");
264 return (
void *)ERROR_PTR(
"lq not defined", procName, NULL);
288 PROCNAME(
"lqueueGetCount");
291 return ERROR_INT(
"lq not defined", procName, 0);
313 PROCNAME(
"lqueuePrint");
316 return ERROR_INT(
"stream not defined", procName, 1);
318 return ERROR_INT(
"lq not defined", procName, 1);
320 fprintf(fp,
"\n L_Queue: nalloc = %d, nhead = %d, nelem = %d, array = %p\n",
322 for (i = lq->
nhead; i < lq->nhead + lq->
nelem; i++)
323 fprintf(fp,
"array[%d] = %p\n", i, lq->
array[i]);
l_int32 lqueueGetCount(L_QUEUE *lq)
lqueueGetCount()
static l_int32 lqueueExtendArray(L_QUEUE *lq)
lqueueExtendArray()
void lqueueDestroy(L_QUEUE **plq, l_int32 freeflag)
lqueueDestroy()
l_ok lqueuePrint(FILE *fp, L_QUEUE *lq)
lqueuePrint()
void * lqueueRemove(L_QUEUE *lq)
lqueueRemove()
l_ok lqueueAdd(L_QUEUE *lq, void *item)
lqueueAdd()
L_QUEUE * lqueueCreate(l_int32 nalloc)
lqueueCreate()
void lstackDestroy(L_STACK **plstack, l_int32 freeflag)
lstackDestroy()
void * reallocNew(void **pindata, size_t oldsize, size_t newsize)
reallocNew()