chaos_queue.c
void* chaos_queue_dequeue(chaos_queue* queue)
{
    queue_entry* entry;
    void* data;
    
    /* Sanity check */
    if(queue == NULL)
        return NULL;
    
    data = NULL;
    
    if(queue->tail != NULL) {
        entry = queue->tail;
        queue->tail = queue->tail->prev;
        
        if(queue->tail != NULL) {
            queue->tail->next = NULL;
        }
        else {
            /* Queue is empty */
            queue->head = NULL;
        }
        
        queue->count--;
        data = entry->data;
        free(entry);
    }
    
    return data;
}
/* Removes data from the end of the queue; i.e.,
   the standard queue operation. */
Removes data from the end of the queue; i.e.,
the standard queue operation.
Removes data from the end of the queue ; i . e . the standard queue operation .
void* chaos_queue_dequeue(chaos_queue* queue)
{
    queue_entry* entry;
    void* data;
    if(queue == NULL)
        return NULL;
    data = NULL;
    if(queue->tail != NULL) {
        entry = queue->tail;
        queue->tail = queue->tail->prev;
        if(queue->tail != NULL) {
            queue->tail->next = NULL;
        }
        else {
            queue->head = NULL;
        }
        queue->count--;
        data = entry->data;
        free(entry);
    }
    return data;
}
void * chaos_queue_dequeue ( chaos_queue * queue ) { queue_entry * entry ; void * data ; if ( queue == NULL ) return NULL ; data = NULL ; if ( queue -> tail != NULL ) { entry = queue -> tail ; queue -> tail = queue -> tail -> prev ; if ( queue -> tail != NULL ) { queue -> tail -> next = NULL ; } else { queue -> head = NULL ; } queue -> count -- ; data = entry -> data ; free ( entry ) ; } return data ; }
Removes data from the end of the queue; i.e.,
the standard queue operation.
Removes data from the end of the queue ; i . e . the standard queue operation .
/* Sanity check */ /* Queue is empty */