diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-05-27 09:03:51 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-05-27 09:03:51 +0200 |
| commit | 7c934801f88c640970ad41b5ddd39f4e39609f28 (patch) | |
| tree | 76a065db76fbcbdec818b8b6cc8b108ac1c9eb49 /src/core | |
| parent | 243a852d31483d10983c50978d1d4471efd0e553 (diff) | |
| download | nissy-core-7c934801f88c640970ad41b5ddd39f4e39609f28.tar.gz nissy-core-7c934801f88c640970ad41b5ddd39f4e39609f28.zip | |
Removed VLA notation from function parameters.
I found out that this gives undefined behavior when then size is 0.
Better not to have it at all, it is confusing for other developers anyway.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/moves.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/core/moves.h b/src/core/moves.h index 5f48f8d..d3ff4a3 100644 --- a/src/core/moves.h +++ b/src/core/moves.h | |||
| @@ -3,13 +3,13 @@ | |||
| 3 | 3 | ||
| 4 | STATIC uint8_t readmove(char); | 4 | STATIC uint8_t readmove(char); |
| 5 | STATIC int64_t readmoves(const char *, | 5 | STATIC int64_t readmoves(const char *, |
| 6 | size_t n, size_t m, uint64_t *, uint64_t *, uint8_t [n], uint8_t [m]); | 6 | size_t, size_t, uint64_t *, uint64_t *, uint8_t *, uint8_t *); |
| 7 | STATIC int64_t countmoves(const char *); | 7 | STATIC int64_t countmoves(const char *); |
| 8 | STATIC uint8_t readmodifier(char); | 8 | STATIC uint8_t readmodifier(char); |
| 9 | STATIC int64_t writemoves(size_t n, const uint8_t [n], size_t m, char [m]); | 9 | STATIC int64_t writemoves(size_t, const uint8_t *, size_t, char *); |
| 10 | 10 | ||
| 11 | STATIC_INLINE bool allowednextmove(uint8_t, uint8_t); | 11 | STATIC_INLINE bool allowednextmove(uint8_t, uint8_t); |
| 12 | STATIC bool allowedmoves(size_t n, const uint8_t [n]); | 12 | STATIC bool allowedmoves(size_t, const uint8_t *); |
| 13 | 13 | ||
| 14 | STATIC_INLINE uint8_t movebase(uint8_t); | 14 | STATIC_INLINE uint8_t movebase(uint8_t); |
| 15 | STATIC_INLINE uint8_t moveaxis(uint8_t); | 15 | STATIC_INLINE uint8_t moveaxis(uint8_t); |
| @@ -24,8 +24,8 @@ STATIC uint8_t transform_move(uint8_t, uint8_t); | |||
| 24 | STATIC cube_t move(cube_t, uint8_t); | 24 | STATIC cube_t move(cube_t, uint8_t); |
| 25 | STATIC cube_t premove(cube_t, uint8_t); | 25 | STATIC cube_t premove(cube_t, uint8_t); |
| 26 | STATIC uint8_t inverse_move(uint8_t); | 26 | STATIC uint8_t inverse_move(uint8_t); |
| 27 | STATIC void sortparallel_moves(size_t n, uint8_t [n]); | 27 | STATIC void sortparallel_moves(size_t, uint8_t*); |
| 28 | STATIC bool are_lastmoves_singlecw(size_t n, const uint8_t [n]); | 28 | STATIC bool are_lastmoves_singlecw(size_t, const uint8_t*); |
| 29 | 29 | ||
| 30 | #define FOREACH_READMOVE(ARG_BUF, ARG_MOVE, ARG_C, ARG_MAX, \ | 30 | #define FOREACH_READMOVE(ARG_BUF, ARG_MOVE, ARG_C, ARG_MAX, \ |
| 31 | RET_ERROR, ARG_ACTION) \ | 31 | RET_ERROR, ARG_ACTION) \ |
| @@ -126,8 +126,8 @@ readmoves( | |||
| 126 | size_t invsize, | 126 | size_t invsize, |
| 127 | uint64_t *n, | 127 | uint64_t *n, |
| 128 | uint64_t *i, | 128 | uint64_t *i, |
| 129 | uint8_t normal[nsize], | 129 | uint8_t *normal, |
| 130 | uint8_t inverse[invsize] | 130 | uint8_t *inverse |
| 131 | ) | 131 | ) |
| 132 | { | 132 | { |
| 133 | uint8_t m; | 133 | uint8_t m; |
| @@ -171,9 +171,9 @@ countmoves(const char *buf) | |||
| 171 | STATIC int64_t | 171 | STATIC int64_t |
| 172 | writemoves( | 172 | writemoves( |
| 173 | size_t nmoves, | 173 | size_t nmoves, |
| 174 | const uint8_t m[nmoves], | 174 | const uint8_t *m, |
| 175 | size_t buf_size, | 175 | size_t buf_size, |
| 176 | char buf[buf_size] | 176 | char *buf |
| 177 | ) | 177 | ) |
| 178 | { | 178 | { |
| 179 | size_t i, len, w; | 179 | size_t i, len, w; |
| @@ -214,7 +214,7 @@ allowednextmove(uint8_t m1, uint8_t m2) | |||
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | STATIC bool | 216 | STATIC bool |
| 217 | allowedmoves(size_t n, const uint8_t m[n]) | 217 | allowedmoves(size_t n, const uint8_t *m) |
| 218 | { | 218 | { |
| 219 | uint8_t j; | 219 | uint8_t j; |
| 220 | 220 | ||
| @@ -422,7 +422,7 @@ inverse_move(uint8_t m) | |||
| 422 | } | 422 | } |
| 423 | 423 | ||
| 424 | STATIC void | 424 | STATIC void |
| 425 | sortparallel_moves(size_t n, uint8_t moves[n]) | 425 | sortparallel_moves(size_t n, uint8_t *moves) |
| 426 | { | 426 | { |
| 427 | uint8_t i; | 427 | uint8_t i; |
| 428 | 428 | ||
| @@ -435,7 +435,7 @@ sortparallel_moves(size_t n, uint8_t moves[n]) | |||
| 435 | } | 435 | } |
| 436 | 436 | ||
| 437 | STATIC bool | 437 | STATIC bool |
| 438 | are_lastmoves_singlecw(size_t n, const uint8_t moves[n]) | 438 | are_lastmoves_singlecw(size_t n, const uint8_t *moves) |
| 439 | { | 439 | { |
| 440 | bool two; | 440 | bool two; |
| 441 | 441 | ||
