src/queue.c
l_int32
lqueueAdd(L_QUEUE  *lq,
          void     *item)
{
    PROCNAME("lqueueAdd");

    if (!lq)
        return ERROR_INT("lq not defined", procName, 1);
    if (!item)
        return ERROR_INT("item not defined", procName, 1);
    
        /* If filled to the end and the ptrs can be shifted to the left,
         * shift them. */
    if ((lq->nhead + lq->nelem >= lq->nalloc) && (lq->nhead != 0)) {
        memmove(lq->array, lq->array + lq->nhead, sizeof(void *) * lq->nelem);
        lq->nhead = 0;
    }

        /* If necessary, expand the allocated array by a factor of 2 */
    if (lq->nelem > 0.75 * lq->nalloc)
        lqueueExtendArray(lq);

        /* Now add the item */
    lq->array[lq->nhead + lq->nelem] = (void *)item;
    lq->nelem++;

    return 0;
}
/*!
 *  lqueueAdd()
 *
 *      Input:  lqueue
 *              item to be added to the tail of the queue
 *      Return: 0 if OK, 1 on error
 *
 *  Notes:
 *      (1) The algorithm is as follows.  If the queue is populated
 *          to the end of the allocated array, shift all ptrs toward
 *          the beginning of the array, so that the head of the queue
 *          is at the beginning of the array.  Then, if the array is
 *          more than 0.75 full, realloc with double the array size.
 *          Finally, add the item to the tail of the queue.
 */
lqueueAdd()
Input:  lqueue
item to be added to the tail of the queue
Return: 0 if OK, 1 on error

(1) The algorithm is as follows.  If the queue is populated
to the end of the allocated array, shift all ptrs toward
the beginning of the array, so that the head of the queue
is at the beginning of the array.  Then, if the array is
more than 0.75 full, realloc with double the array size.
Finally, add the item to the tail of the queue.
lqueueAdd () Input : lqueue item to be added to the tail of the queue Return : 0 if OK 1 on error ( 1 ) The algorithm is as follows . If the queue is populated to the end of the allocated array shift all ptrs toward the beginning of the array so that the head of the queue is at the beginning of the array . Then if the array is more than 0 . 75 full realloc with double the array size . Finally add the item to the tail of the queue .
l_int32
lqueueAdd(L_QUEUE  *lq,
          void     *item)
{
    PROCNAME("lqueueAdd");
    if (!lq)
        return ERROR_INT("lq not defined", procName, 1);
    if (!item)
        return ERROR_INT("item not defined", procName, 1);
    if ((lq->nhead + lq->nelem >= lq->nalloc) && (lq->nhead != 0)) {
        memmove(lq->array, lq->array + lq->nhead, sizeof(void *) * lq->nelem);
        lq->nhead = 0;
    }
    if (lq->nelem > 0.75 * lq->nalloc)
        lqueueExtendArray(lq);
    lq->array[lq->nhead + lq->nelem] = (void *)item;
    lq->nelem++;
    return 0;
}
l_int32 lqueueAdd ( L_QUEUE * lq , void * item ) { PROCNAME ( " " ) ; if ( ! lq ) return ERROR_INT ( " " , procName , 1 ) ; if ( ! item ) return ERROR_INT ( " " , procName , 1 ) ; if ( ( lq -> nhead + lq -> nelem >= lq -> nalloc ) && ( lq -> nhead != 0 ) ) { memmove ( lq -> array , lq -> array + lq -> nhead , sizeof ( void * ) * lq -> nelem ) ; lq -> nhead = 0 ; } if ( lq -> nelem > 0.75 * lq -> nalloc ) lqueueExtendArray ( lq ) ; lq -> array [ lq -> nhead + lq -> nelem ] = ( void * ) item ; lq -> nelem ++ ; return 0 ; }
lqueueAdd()
      Input:  lqueue
              item to be added to the tail of the queue
      Return: 0 if OK, 1 on error
lqueueAdd () Input : lqueue item to be added to the tail of the queue Return : 0 if OK 1 on error
/* If filled to the end and the ptrs can be shifted to the left,
         * shift them. */ /* If necessary, expand the allocated array by a factor of 2 */ /* Now add the item */