aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-01-07 12:56:37 +0100
committerHampusM <hampus@hampusmat.com>2022-01-07 12:56:37 +0100
commit977c46591583a59f8d51773ffaba08b5076a426e (patch)
treea04727c2075cebe0ae8b93728c9071e164a17c43 /src
parent2876d7efdeac80085a04b8f1c509065bf323f70e (diff)
style: fix minor code formatting issues
Diffstat (limited to 'src')
-rw-r--r--src/grid.c3
-rw-r--r--src/grid.h1
-rw-r--r--src/maze.c9
-rw-r--r--src/maze.h2
-rw-r--r--src/mazerator.c6
-rw-r--r--src/position.c1
-rw-r--r--src/position.h1
-rw-r--r--src/utils.c7
8 files changed, 12 insertions, 18 deletions
diff --git a/src/grid.c b/src/grid.c
index 372ea7e..3554779 100644
--- a/src/grid.c
+++ b/src/grid.c
@@ -1,7 +1,7 @@
#include "grid.h"
#include "utils.h"
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
Grid grid_create(unsigned int width, unsigned int height, char *fill)
{
@@ -53,4 +53,3 @@ void grid_destroy(Grid grid)
free(grid.grid);
}
-
diff --git a/src/grid.h b/src/grid.h
index 65fa01a..262035e 100644
--- a/src/grid.h
+++ b/src/grid.h
@@ -56,4 +56,3 @@ void grid_print(Grid grid);
void grid_destroy(Grid grid);
#endif
-
diff --git a/src/maze.c b/src/maze.c
index bae1ba4..5a59c76 100644
--- a/src/maze.c
+++ b/src/maze.c
@@ -1,10 +1,10 @@
#include "maze.h"
#include "grid.h"
#include "position.h"
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdint.h>
int is_pos_empty(Grid grid, Position pos)
{
@@ -15,10 +15,10 @@ void add_neighbour(Position neighbours[], uint8_t *neighbour_cnt, Position neigh
{
neighbours[*neighbour_cnt] = neighbour_pos;
(*neighbour_cnt)++;
-
}
-void get_neighbours(Grid grid, Position pos, Position neighbours[], uint8_t *neighbour_cnt)
+void get_neighbours(Grid grid, Position pos, Position neighbours[],
+ uint8_t *neighbour_cnt)
{
if (pos.y != 1)
{
@@ -96,7 +96,7 @@ void grid_to_maze(Grid grid, Position start_pos)
Position next_pos = neighbours[rand() % neighbour_cnt];
Position between_pos = position_create(pos.x, pos.y);
-
+
if (next_pos.y != pos.y)
between_pos.y += next_pos.y > pos.y ? 1 : -1;
@@ -110,4 +110,3 @@ void grid_to_maze(Grid grid, Position start_pos)
pos_stack_destroy(path);
}
-
diff --git a/src/maze.h b/src/maze.h
index 1a3937f..a3c932c 100644
--- a/src/maze.h
+++ b/src/maze.h
@@ -1,8 +1,8 @@
#ifndef MAZE_H
#define MAZE_H
-#include "position_stack.h"
#include "grid.h"
+#include "position_stack.h"
/**
* Creates a maze from a grid
diff --git a/src/mazerator.c b/src/mazerator.c
index 593d518..c624dc3 100644
--- a/src/mazerator.c
+++ b/src/mazerator.c
@@ -1,5 +1,5 @@
-#include "maze.h"
#include "grid.h"
+#include "maze.h"
#include "position.h"
#include "utils.h"
#include <getopt.h>
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
{
case 'w':
maze_width = str_to_uint(optarg, &err);
-
+
if (err != NULL)
optarg_error(arg, err);
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
break;
case 'h':
maze_height = str_to_uint(optarg, &err);
-
+
if (err != NULL)
optarg_error(arg, err);
diff --git a/src/position.c b/src/position.c
index 937edd5..a7465ab 100644
--- a/src/position.c
+++ b/src/position.c
@@ -6,4 +6,3 @@ Position position_create(unsigned int x, unsigned int y)
return pos;
}
-
diff --git a/src/position.h b/src/position.h
index d1bc9eb..05d21fa 100644
--- a/src/position.h
+++ b/src/position.h
@@ -10,4 +10,3 @@ typedef struct Position
Position position_create(unsigned int x, unsigned int y);
#endif
-
diff --git a/src/utils.c b/src/utils.c
index 2657a00..5fc27d3 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,9 +1,9 @@
#include "utils.h"
#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
void *malloc_s(unsigned long amount)
{
@@ -43,4 +43,3 @@ unsigned int str_to_uint(char *str, char **err)
return (unsigned int)num;
}
-