DMU380SA Series
User’s Manual
________________________________________________________________________
Doc# 7430-0026 Rev. 01
Page 86
queue_ptr->rear = -1;
}
/*******************************************************************************
* FUNCTION: AddQueue - add item in front of queue
* ARGUMENTS: item holds item to be added to queue
*
queue_ptr is pointer to the queue
* RETURNS:
returns 0 if queue is full. 1 if successful
*******************************************************************************/
int AddQueue(char item, QUEUE_TYPE *queue_ptr)
{
int retval = 0;
if(queue_ptr->count >= MAXQUEUE)
{
retval = 0;
/* queue is full */
}
else
{
queue_ptr->count++;
queue_ptr->rear = (queue_ptr->rear + 1) % MAXQUEUE;
queue_ptr->entry[queue_ptr->rear] = item;
retval = 1;
}
return retval;
}
/*******************************************************************************
* FUNCTION: DeleteQeue - return an item from the queue
* ARGUMENTS: item will hold item popped from queue
*
queue_ptr is pointer to the queue
* RETURNS:
returns 0 if queue is empty. 1 if successful
*******************************************************************************/
int DeleteQueue(char *item, QUEUE_TYPE *queue_ptr)
{
int retval = 0;
if(queue_ptr->count <= 0)
{
retval = 0; /* queue is empty */
}
else
{
queue_ptr -> count--;
*item = queue_ptr->entry[queue_ptr->front];
queue_ptr->front = (queue_ptr->front+1) % MAXQUEUE;
retval=1;