fix: add domino files
This commit is contained in:
parent
e7bfbbc35c
commit
eb1d517332
12
domino.c
Normal file
12
domino.c
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
23
domino.h
Normal file
23
domino.h
Normal file
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue