summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--domino.c12
-rw-r--r--domino.h23
2 files changed, 35 insertions, 0 deletions
diff --git a/domino.c b/domino.c
new file mode 100644
index 0000000..cdaa52d
--- /dev/null
+++ b/domino.c
@@ -0,0 +1,12 @@
+#include <stdlib.h>
+#include "domino.h"
+
+void bricks_append(struct bricks *bricks, struct brick brick) {
+ if (bricks->count+1 > bricks->capacity) {
+ if (bricks->capacity == 0) bricks->capacity = 256;
+ while (bricks->count+1 > bricks->capacity) bricks->capacity *= 2;
+ bricks->items.brick = realloc(bricks->items.brick, bricks->capacity * sizeof(*bricks->items.brick));
+ }
+ bricks->items.brick[bricks->count++] = brick;
+}
+
diff --git a/domino.h b/domino.h
new file mode 100644
index 0000000..b08c332
--- /dev/null
+++ b/domino.h
@@ -0,0 +1,23 @@
+#include <stddef.h>
+
+#ifndef DOMINO_H
+#define DOMINO_H
+
+struct eye {
+ int x,y,val;
+};
+
+struct brick {
+ struct eye front, back;
+};
+
+struct bricks {
+ size_t capacity, count;
+ union {struct eye *eye; struct brick *brick;} items;
+};
+
+void bricks_append(struct bricks *bricks, struct brick brick);
+
+#endif // DOMINO_H
+
+