chaos_queue.c
int chaos_queue_enqueue(chaos_queue* queue, void* data)
{
    queue_entry* entry;
    
    /* Sanity check */
    if(queue == NULL)
        return 1;
    
    entry = alloc_entry();
    entry->data = data;
    
    if(queue->head == NULL) {
        /* Queue is empty! */
        queue->head = entry;
        queue->tail = entry;
        queue->count++;
    }
    else {
        /* It's a queue, so we add to the front */
        entry->next = queue->head;
        queue->head->prev = entry;
        queue->head = entry;
        
        queue->count++;
    }
    
    return 0;
}
/* Adds the data to the front of the queue */
Adds the data to the front of the queue
Adds the data to the front of the queue
int chaos_queue_enqueue(chaos_queue* queue, void* data)
{
    queue_entry* entry;
    if(queue == NULL)
        return 1;
    entry = alloc_entry();
    entry->data = data;
    if(queue->head == NULL) {
        queue->head = entry;
        queue->tail = entry;
        queue->count++;
    }
    else {
        entry->next = queue->head;
        queue->head->prev = entry;
        queue->head = entry;
        queue->count++;
    }
    return 0;
}
int chaos_queue_enqueue ( chaos_queue * queue , void * data ) { queue_entry * entry ; if ( queue == NULL ) return 1 ; entry = alloc_entry ( ) ; entry -> data = data ; if ( queue -> head == NULL ) { queue -> head = entry ; queue -> tail = entry ; queue -> count ++ ; } else { entry -> next = queue -> head ; queue -> head -> prev = entry ; queue -> head = entry ; queue -> count ++ ; } return 0 ; }
Adds the data to the front of the queue
Adds the data to the front of the queue
/* Sanity check */ /* Queue is empty! */ /* It's a queue, so we add to the front */