summaryrefslogtreecommitdiff
path: root/anim/tools/heap.c
diff options
context:
space:
mode:
Diffstat (limited to 'anim/tools/heap.c')
-rw-r--r--anim/tools/heap.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/anim/tools/heap.c b/anim/tools/heap.c
new file mode 100644
index 0000000..3c95f07
--- /dev/null
+++ b/anim/tools/heap.c
@@ -0,0 +1,31 @@
+#include <stdlib.h>
+
+typedef struct node {
+ long value;
+ struct node *next;
+} node;
+
+node *head;
+
+void push(long value) {
+ node *n = malloc(sizeof *n);
+ n->value = value;
+ n->next = head;
+ head = n;
+}
+
+void pop(void) {
+ node *n = head;
+ head = n->next;
+ free(n);
+}
+
+int main(void) {
+ push(7);
+ push(12);
+ push(9);
+ pop();
+ pop();
+ push(25);
+ return 0;
+}