diff options
| author | emmadoth <emmadoth@disroot.org> | 2023-06-08 22:42:41 +0200 |
|---|---|---|
| committer | emmadoth <emmadoth@disroot.org> | 2023-06-08 22:42:41 +0200 |
| commit | d074e9de89070c5091af7cd00fc7a5910751d225 (patch) | |
| tree | 197bdaf6e651db98bbf3cc96443ac719aca12b65 /main.c | |
| parent | b750c0127fb5040d7c641ef9f2147fee807d304a (diff) | |
fix warnings, fix return type of input handler
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -3,7 +3,7 @@ #include <string.h> #include <ncurses.h> -#define F_ARGS _Size* size, _Bool (*board)[size->width], char (*neighbours)[size->width], int y, int x +#define F_ARGS _Size* size, _Bool (*board)[size->width], [[maybe_unused]] char (*neighbours)[size->width], int y, int x typedef struct { int height; @@ -62,7 +62,7 @@ void apply_rules(F_ARGS) } } -int handle_input(int input) +_Bool handle_input(int input) { switch(input) { @@ -84,11 +84,11 @@ int main(void) _Size size; getmaxyx(stdscr, size.height, size.width); - _Bool (*board )[size.width] = malloc(size.height * size.width * sizeof(_Bool)); - char (*neighbours)[size.width] = malloc(size.height * size.width * sizeof(char )); + _Bool (*board )[size.width] = malloc((size_t)size.height * (size_t)size.width * sizeof(_Bool)); + char (*neighbours)[size.width] = malloc((size_t)size.height * (size_t)size.width * sizeof(char )); - memset(board , 0, size.height * size.width * sizeof(_Bool)); - memset(neighbours, 0, size.height * size.width * sizeof(char )); + memset(board , 0, (size_t)size.height * (size_t)size.width * sizeof(_Bool)); + memset(neighbours, 0, (size_t)size.height * (size_t)size.width * sizeof(char )); board[0][1] = 1; board[1][2] = 1; @@ -114,7 +114,7 @@ int main(void) input = getch(); run = handle_input(input); - memset(neighbours, 0, size.height * size.width * sizeof(char )); + memset(neighbours, 0, (size_t)size.height * (size_t)size.width * sizeof(char )); } free(board); |
