aboutsummaryrefslogtreecommitdiff
path: root/src/grid.c
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-01-09 21:47:23 +0100
committerHampusM <hampus@hampusmat.com>2022-01-09 21:47:23 +0100
commit8ceb79db1d0687bba005cef4a77bb889bf7ec3c3 (patch)
treeb7c13359f652506d60c8556ea386ae8d50bfc5bc /src/grid.c
parent097aa95c1f0cb159e7d9d0a3edf9284c421ee298 (diff)
refactor: rewrite to c++
Diffstat (limited to 'src/grid.c')
-rw-r--r--src/grid.c55
1 files changed, 0 insertions, 55 deletions
diff --git a/src/grid.c b/src/grid.c
deleted file mode 100644
index 1ad01cd..0000000
--- a/src/grid.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "grid.h"
-#include "utils.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-Grid grid_create(unsigned int width, unsigned int height, char *fill)
-{
- unsigned int mem_height = height * sizeof(char **);
- unsigned int mem_width = width * sizeof(char *);
-
- Dimensions dimens = {.width = width, .height = height};
-
- Grid grid = {.grid = malloc_s(mem_height), .dimens = dimens};
-
- // Fill the grid
- for (unsigned int y = 0U; y < height; y++)
- {
- grid.grid[y] = malloc_s(mem_width);
-
- for (unsigned int x = 0U; x < width; x++)
- grid.grid[y][x] = fill;
- }
-
- return grid;
-}
-
-char *grid_get(Grid grid, Position pos)
-{
- return grid.grid[pos.y][pos.x];
-}
-
-void grid_set(Grid grid, Position pos, char *value)
-{
- grid.grid[pos.y][pos.x] = value;
-}
-
-void grid_print(Grid grid)
-{
- for (unsigned int y = 0U; y < grid.dimens.height; y++)
- {
- for (unsigned int x = 0U; x < grid.dimens.width; x++)
- printf("%s", grid.grid[y][x]);
-
- printf("\n");
- }
-}
-
-void grid_destroy(Grid grid)
-{
- // Deallocate the memory of the grid
- for (unsigned int y = 0U; y < grid.dimens.height; y++)
- free(grid.grid[y]);
-
- free(grid.grid);
-}