#include "queue.h" #include #include queue *initialize_queue() { queue *q; q = (queue *) malloc(sizeof(queue *)); return q; } void enqueue(queue * q, worker * w) { struct node *aux; if (q->head == NULL) { q->head = (struct node *) malloc(sizeof(struct node *)); q->head->next = NULL; q->head->value = w; q->tail = q->head; return; } else { aux = (struct node *) malloc(sizeof(struct node *)); aux->next = NULL; aux->value = w; q->tail->next = aux; q->tail = aux; } } worker *dequeue(queue * q) { struct node *aux; worker *ret_val; ret_val = q->head->value; aux = q->head; q->head = q->head->next; free(aux); return (ret_val); } void destroy_queue(queue * q) { struct node *aux, *next; aux = q->head; while (aux != NULL) { next = aux->next; free(aux); if (next != NULL) aux = next; } free(q); }