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 if (nalloc < MIN_BUFFER_SIZE)
98 nalloc = INITIAL_BUFFER_ARRAYSIZE;
101 if ((lq->
array = (
void **)LEPT_CALLOC(nalloc,
sizeof(
void *))) == NULL) {
103 return (
L_QUEUE *)ERROR_PTR(
"ptr array not made", __func__, NULL);
139 L_WARNING(
"ptr address is NULL\n", __func__);
142 if ((lq = *plq) == NULL)
146 while(lq->
nelem > 0) {
150 }
else if (lq->
nelem > 0) {
151 L_WARNING(
"memory leak of %d items in lqueue!\n", __func__, lq->
nelem);
155 LEPT_FREE(lq->
array);
188 return ERROR_INT(
"lq not defined", __func__, 1);
190 return ERROR_INT(
"item not defined", __func__, 1);
202 return ERROR_INT(
"extension failed", __func__, 1);
223 return ERROR_INT(
"lq not defined", __func__, 1);
226 sizeof(
void *) * lq->
nalloc,
227 2 *
sizeof(
void *) * lq->
nalloc)) == NULL)
228 return ERROR_INT(
"new ptr array not returned", __func__, 1);
254 return (
void *)ERROR_PTR(
"lq not defined", __func__, NULL);
279 return ERROR_INT(
"lq not defined", __func__, 0);
302 return ERROR_INT(
"stream not defined", __func__, 1);
304 return ERROR_INT(
"lq not defined", __func__, 1);
306 fprintf(fp,
"\n L_Queue: nalloc = %d, nhead = %d, nelem = %d, array = %p\n",
308 for (i = lq->
nhead; i < lq->nhead + lq->
nelem; i++)
309 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()