This commit is contained in:
2026-04-20 20:09:16 +02:00
commit a97f290271
22 changed files with 451 additions and 0 deletions
@@ -0,0 +1,35 @@
#include "parsing.h"
#include <stdlib.h>
struct queue *enqueue(struct queue *queue, struct node *node) {
struct queue *new_elt = malloc(sizeof(struct queue));
if (!new_elt)
return queue;
new_elt->node = node;
new_elt->next = NULL;
if (!queue) {
return new_elt;
}
struct queue *it = queue;
while (it->next) {
it = it->next;
}
it->next = new_elt;
return queue;
}
struct node *dequeue(struct queue **queue) {
if (!queue || !*queue)
return NULL;
struct node *res = (*queue)->node;
struct queue *temp = *queue;
*queue = (*queue)->next;
free(temp);
return res;
}
void queue_destroy(struct queue *queue) {
while (queue) {
dequeue(&queue);
}
}