aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-05-27 09:03:51 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-05-27 09:03:51 +0200
commit7c934801f88c640970ad41b5ddd39f4e39609f28 (patch)
tree76a065db76fbcbdec818b8b6cc8b108ac1c9eb49 /src/utils
parent243a852d31483d10983c50978d1d4471efd0e553 (diff)
downloadnissy-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/utils')
-rw-r--r--src/utils/math.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/utils/math.h b/src/utils/math.h
index 3ecd313..732a031 100644
--- a/src/utils/math.h
+++ b/src/utils/math.h
@@ -4,12 +4,12 @@
4#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) 4#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
5 5
6STATIC int64_t factorial(int64_t); 6STATIC int64_t factorial(int64_t);
7STATIC bool isperm(size_t n, const uint8_t [n]); 7STATIC bool isperm(size_t, const uint8_t *);
8STATIC int64_t permtoindex(size_t n, const uint8_t [n]); 8STATIC int64_t permtoindex(size_t, const uint8_t *);
9STATIC void indextoperm(int64_t, size_t n, uint8_t [n]); 9STATIC void indextoperm(int64_t, size_t, uint8_t *);
10STATIC int permsign(size_t n, const uint8_t [n]); 10STATIC int permsign(size_t, const uint8_t *);
11STATIC int64_t digitstosumzero(size_t n, const uint8_t [n], uint8_t); 11STATIC int64_t digitstosumzero(size_t, const uint8_t *, uint8_t);
12STATIC void sumzerotodigits(int64_t, size_t n, uint8_t, uint8_t [n]); 12STATIC void sumzerotodigits(int64_t, size_t, uint8_t, uint8_t *);
13STATIC double intpow(double, uint64_t); 13STATIC double intpow(double, uint64_t);
14 14
15STATIC int64_t 15STATIC int64_t
@@ -33,7 +33,7 @@ factorial(int64_t n)
33} 33}
34 34
35STATIC bool 35STATIC bool
36isperm(size_t n, const uint8_t a[n]) 36isperm(size_t n, const uint8_t *a)
37{ 37{
38 size_t i; 38 size_t i;
39 bool aux[FACTORIAL_MAX+1]; 39 bool aux[FACTORIAL_MAX+1];
@@ -61,7 +61,7 @@ isperm(size_t n, const uint8_t a[n])
61} 61}
62 62
63STATIC int64_t 63STATIC int64_t
64permtoindex(size_t n, const uint8_t a[n]) 64permtoindex(size_t n, const uint8_t *a)
65{ 65{
66 size_t i, j; 66 size_t i, j;
67 int64_t c, ret; 67 int64_t c, ret;
@@ -85,7 +85,7 @@ permtoindex(size_t n, const uint8_t a[n])
85} 85}
86 86
87STATIC void 87STATIC void
88indextoperm(int64_t p, size_t n, uint8_t r[n]) 88indextoperm(int64_t p, size_t n, uint8_t *r)
89{ 89{
90 int64_t c; 90 int64_t c;
91 size_t i, j; 91 size_t i, j;
@@ -120,7 +120,7 @@ indextoperm_error:
120} 120}
121 121
122STATIC int 122STATIC int
123permsign(size_t n, const uint8_t a[n]) 123permsign(size_t n, const uint8_t *a)
124{ 124{
125 size_t i, j, ret; 125 size_t i, j, ret;
126 126
@@ -132,7 +132,7 @@ permsign(size_t n, const uint8_t a[n])
132} 132}
133 133
134STATIC int64_t 134STATIC int64_t
135digitstosumzero(size_t n, const uint8_t a[n], uint8_t b) 135digitstosumzero(size_t n, const uint8_t *a, uint8_t b)
136{ 136{
137 int64_t ret, p; 137 int64_t ret, p;
138 size_t i, sum; 138 size_t i, sum;
@@ -162,7 +162,7 @@ digitstosumzero(size_t n, const uint8_t a[n], uint8_t b)
162} 162}
163 163
164STATIC void 164STATIC void
165sumzerotodigits(int64_t d, size_t n, uint8_t b, uint8_t a[n]) 165sumzerotodigits(int64_t d, size_t n, uint8_t b, uint8_t *a)
166{ 166{
167 uint8_t sum; 167 uint8_t sum;
168 size_t i; 168 size_t i;

Generated with cgit - Back to sebastiano.tronto.net