--- /dev/null
+*.o
+*.geany
+demo
+
--- /dev/null
+CC = gcc
+CFLAGS = -Wall -g
+DEPS = queue.h stack.h
+
+%.o: %.c $(DEPS)
+ $(CC) $< $(CFLAGS) -c -o $@
+
+demo: demo.o queue.o stack.o
+ $(CC) $(CFLAGS) -o demo demo.o queue.o stack.o
+
+clean:
+ rm -rf *.dSYM *.so *.a *.o demo
+
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include "queue.h"
+#include "stack.h"
+
+int main() {
+ Stack* stack = stack_init();
+ if (stack_empty(stack))
+ printf("Stack is empty\n");
+
+ int* i = malloc(sizeof(int*));
+ *i = 10;
+ stack_push(stack, i);
+ int* j = malloc(sizeof(int*));
+ *j = 5;
+ stack_push(stack, j);
+ int* val = stack_pop(stack);
+ printf("Stack back: %i\n", *val);
+ free(val);
+ void** elems = stack_clear(&stack);
+ for (int i = 0; elems[i]; i++)
+ free(elems[i]);
+ free(elems);
+
+ return 0;
+}
+
--- /dev/null
+#include <stdlib.h>
+#include "queue.h"
+
+void* queue_pop() {
+ return NULL;
+}
+
+void queue_push(void*) {
+}
+
+void* queue_front() {
+ return NULL;
+}
+
+void* queue_back() {
+ return NULL;
+}
+
+void queue_clear() {
+}
--- /dev/null
+
+#ifndef _QUEUE_H_
+#define _QUEUE_H_
+
+void* queue_pop();
+void queue_push(void*);
+void* queue_front();
+void* queue_back();
+void queue_clear();
+
+#endif
--- /dev/null
+#include <stdlib.h>
+#include "stack.h"
+
+typedef struct _Stack {
+ void** elems;
+ int size;
+} Stack;
+
+Stack* stack_init() {
+ Stack* s = malloc(sizeof(Stack));
+ s->size = 0;
+ s->elems = NULL;
+ return s;
+}
+
+void* stack_pop(Stack* stack) {
+ if (stack_empty(stack))
+ return NULL;
+ stack->size -= 1;
+ void* elem = stack->elems[stack->size];
+ stack->elems[stack->size] = NULL;
+ stack->elems = realloc(stack->elems, stack->size * sizeof(void*));
+
+ return elem;
+}
+
+void stack_push(Stack* stack, void* elem) {
+ if (stack == NULL)
+ return;
+
+ stack->size += 1;
+ stack->elems = realloc(stack->elems, stack->size * sizeof(void*));
+ stack->elems[stack->size - 1] = elem;
+}
+
+void* stack_peek(Stack* stack) {
+ if (stack_empty(stack))
+ return NULL;
+ return stack->elems[stack->size - 1];
+}
+
+bool stack_empty(Stack* stack) {
+ return (stack == NULL || stack->size == 0);
+}
+
+void** stack_clear(Stack** stack) {
+ if (*stack == NULL)
+ return NULL;
+ void** elems = (*stack)->elems;
+ free(*stack);
+ *stack = NULL;
+ return elems;
+}
--- /dev/null
+#ifndef _STACK_H_
+#define _STACK_H_
+
+#include <stdbool.h>
+
+typedef struct _Stack Stack;
+
+Stack* stack_init();
+void* stack_pop(Stack*);
+void stack_push(Stack*, void*);
+void* stack_peek(Stack*);
+bool stack_empty(Stack*);
+void** stack_clear(Stack** stack);
+
+#endif