diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-21 14:33:01 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-21 14:44:07 +0200 |
| commit | 510a7471348788fccba6b7c4b9f7b7cc9aee6ba9 (patch) | |
| tree | 58df7791242d9a4f52e80da93ad3af20ed5e3528 /src/solvers/coord/common.h | |
| parent | 1d9b8acfeece68c4f55d2499d8aed127f98a383c (diff) | |
| download | nissy-core-510a7471348788fccba6b7c4b9f7b7cc9aee6ba9.tar.gz nissy-core-510a7471348788fccba6b7c4b9f7b7cc9aee6ba9.zip | |
Always use unsigned char * for data buffers
Before this commit I was inconsistently using one of void *, char *
and uint8_t *.
Diffstat (limited to 'src/solvers/coord/common.h')
| -rw-r--r-- | src/solvers/coord/common.h | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h index 2eb5ad0..8fd405c 100644 --- a/src/solvers/coord/common.h +++ b/src/solvers/coord/common.h | |||
| @@ -1,25 +1,29 @@ | |||
| 1 | STATIC uint64_t coord_coord_generic( | 1 | STATIC uint64_t coord_coord_generic( |
| 2 | const coord_t [static 1], cube_t, const void *); | 2 | const coord_t [static 1], cube_t, const unsigned char *); |
| 3 | STATIC cube_t coord_cube_generic( | 3 | STATIC cube_t coord_cube_generic( |
| 4 | const coord_t [static 1], uint64_t, const void *); | 4 | const coord_t [static 1], uint64_t, const unsigned char *); |
| 5 | STATIC bool coord_isnasty_generic( | 5 | STATIC bool coord_isnasty_generic( |
| 6 | const coord_t [static 1], uint64_t, const void *); | 6 | const coord_t [static 1], uint64_t, const unsigned char *); |
| 7 | STATIC size_t coord_gendata_generic(const coord_t [static 1], void *); | 7 | STATIC size_t coord_gendata_generic(const coord_t [static 1], unsigned char *); |
| 8 | 8 | ||
| 9 | STATIC void append_coord_name(const coord_t [static 1], char *); | 9 | STATIC void append_coord_name(const coord_t [static 1], char *); |
| 10 | STATIC bool solution_lastqt_cw(const solution_moves_t [static 1]); | 10 | STATIC bool solution_lastqt_cw(const solution_moves_t [static 1]); |
| 11 | STATIC bool coord_can_switch( | 11 | STATIC bool coord_can_switch(const coord_t [static 1], const unsigned char *, |
| 12 | const coord_t [static 1], const void *, size_t n, const uint8_t [n]); | 12 | size_t n, const uint8_t [n]); |
| 13 | 13 | ||
| 14 | STATIC uint64_t | 14 | STATIC uint64_t |
| 15 | coord_coord_generic(const coord_t coord[static 1], cube_t c, const void *data) | 15 | coord_coord_generic( |
| 16 | const coord_t coord[static 1], | ||
| 17 | cube_t c, | ||
| 18 | const unsigned char *data | ||
| 19 | ) | ||
| 16 | { | 20 | { |
| 17 | const char *datanoinfo; | 21 | const unsigned char *datanoinfo; |
| 18 | const uint32_t *data32; | 22 | const uint32_t *data32; |
| 19 | uint32_t d; | 23 | uint32_t d; |
| 20 | cube_t tr; | 24 | cube_t tr; |
| 21 | 25 | ||
| 22 | datanoinfo = (const char *)data + INFOSIZE; | 26 | datanoinfo = data + INFOSIZE; |
| 23 | data32 = (const uint32_t *)datanoinfo; | 27 | data32 = (const uint32_t *)datanoinfo; |
| 24 | d = data32[coord->sym.coord(c)]; | 28 | d = data32[coord->sym.coord(c)]; |
| 25 | tr = transform(c, COORD_TTREP(d)); | 29 | tr = transform(c, COORD_TTREP(d)); |
| @@ -28,13 +32,17 @@ coord_coord_generic(const coord_t coord[static 1], cube_t c, const void *data) | |||
| 28 | } | 32 | } |
| 29 | 33 | ||
| 30 | STATIC cube_t | 34 | STATIC cube_t |
| 31 | coord_cube_generic(const coord_t coord[static 1], uint64_t i, const void *data) | 35 | coord_cube_generic( |
| 36 | const coord_t coord[static 1], | ||
| 37 | uint64_t i, | ||
| 38 | const unsigned char *data | ||
| 39 | ) | ||
| 32 | { | 40 | { |
| 33 | const char *datanoinfo; | 41 | const unsigned char *datanoinfo; |
| 34 | const uint32_t *rep32; | 42 | const uint32_t *rep32; |
| 35 | cube_t c; | 43 | cube_t c; |
| 36 | 44 | ||
| 37 | datanoinfo = (const char *)data + INFOSIZE; | 45 | datanoinfo = data + INFOSIZE; |
| 38 | rep32 = (const uint32_t *)(datanoinfo + 4 * (size_t)coord->sym.max); | 46 | rep32 = (const uint32_t *)(datanoinfo + 4 * (size_t)coord->sym.max); |
| 39 | c = coord->sym.cube(rep32[i / coord->sym.max2]); | 47 | c = coord->sym.cube(rep32[i / coord->sym.max2]); |
| 40 | 48 | ||
| @@ -45,14 +53,14 @@ STATIC bool | |||
| 45 | coord_isnasty_generic( | 53 | coord_isnasty_generic( |
| 46 | const coord_t coord[static 1], | 54 | const coord_t coord[static 1], |
| 47 | uint64_t i, | 55 | uint64_t i, |
| 48 | const void *data | 56 | const unsigned char *data |
| 49 | ) | 57 | ) |
| 50 | { | 58 | { |
| 51 | const char *datanoinfo; | 59 | const unsigned char *datanoinfo; |
| 52 | const uint32_t *classttrep, *rep32; | 60 | const uint32_t *classttrep, *rep32; |
| 53 | uint32_t r; | 61 | uint32_t r; |
| 54 | 62 | ||
| 55 | datanoinfo = (const char *)data + INFOSIZE; | 63 | datanoinfo = data + INFOSIZE; |
| 56 | classttrep = (const uint32_t *)datanoinfo; | 64 | classttrep = (const uint32_t *)datanoinfo; |
| 57 | rep32 = (const uint32_t *)(datanoinfo + 4 * (size_t)coord->sym.max); | 65 | rep32 = (const uint32_t *)(datanoinfo + 4 * (size_t)coord->sym.max); |
| 58 | r = rep32[i / coord->sym.max2]; | 66 | r = rep32[i / coord->sym.max2]; |
| @@ -63,11 +71,11 @@ coord_isnasty_generic( | |||
| 63 | STATIC size_t | 71 | STATIC size_t |
| 64 | coord_gendata_generic( | 72 | coord_gendata_generic( |
| 65 | const coord_t coord[static 1], | 73 | const coord_t coord[static 1], |
| 66 | void *data | 74 | unsigned char *data |
| 67 | ) | 75 | ) |
| 68 | { | 76 | { |
| 69 | uint64_t i, j, n, t, nasty; | 77 | uint64_t i, j, n, t, nasty; |
| 70 | char *datanoinfo; | 78 | unsigned char *datanoinfo; |
| 71 | uint32_t *classttrep, *rep; | 79 | uint32_t *classttrep, *rep; |
| 72 | size_t coord_datasize; | 80 | size_t coord_datasize; |
| 73 | cube_t c; | 81 | cube_t c; |
| @@ -78,7 +86,7 @@ coord_gendata_generic( | |||
| 78 | if (data == NULL) | 86 | if (data == NULL) |
| 79 | return coord_datasize; | 87 | return coord_datasize; |
| 80 | 88 | ||
| 81 | datanoinfo = (char *)data + INFOSIZE; | 89 | datanoinfo = data + INFOSIZE; |
| 82 | classttrep = (uint32_t *)datanoinfo; | 90 | classttrep = (uint32_t *)datanoinfo; |
| 83 | rep = classttrep + coord->sym.max; | 91 | rep = classttrep + coord->sym.max; |
| 84 | memset(data, 0xFF, coord_datasize); | 92 | memset(data, 0xFF, coord_datasize); |
| @@ -154,7 +162,7 @@ solution_lastqt_cw(const solution_moves_t s[static 1]) | |||
| 154 | STATIC bool | 162 | STATIC bool |
| 155 | coord_can_switch( | 163 | coord_can_switch( |
| 156 | const coord_t coord[static 1], | 164 | const coord_t coord[static 1], |
| 157 | const void *data, | 165 | const unsigned char *data, |
| 158 | size_t n, | 166 | size_t n, |
| 159 | const uint8_t moves[n] | 167 | const uint8_t moves[n] |
| 160 | ) | 168 | ) |
