aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-10-03 20:27:51 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-10-03 20:27:51 +0200
commit2fdc8dba3690419f2b0dd12b3d6d1c391cc54ba2 (patch)
tree4d9dbbc4a3b202c5edbf218293042e87cca186fd
parent4b3fcb1b0187b55ddaedfc87a39c518fb9cac365 (diff)
Don’t require arg to be passed by reference
-rwxr-xr-xgen/prop/cm.c2
-rw-r--r--include/array.h8
-rw-r--r--test/_brk-test.h2
-rw-r--r--test/_norm-test.h2
-rw-r--r--test/array-test.c2
-rw-r--r--test/wbrk-human-test.c4
6 files changed, 10 insertions, 10 deletions
diff --git a/gen/prop/cm.c b/gen/prop/cm.c
index 3cb4a00..7fb1d7e 100755
--- a/gen/prop/cm.c
+++ b/gen/prop/cm.c
@@ -59,7 +59,7 @@ main(void)
m += rtoucs(buf, sizeof(buf), ch);
assert(n >= m);
- array_push(&maps, ((struct mapping){
+ array_push(maps, ((struct mapping){
.k = (uint64_t)rv.p[0] << 32 | rv.p[1],
.v = ch,
}));
diff --git a/include/array.h b/include/array.h
index 11d8180..f8090cf 100644
--- a/include/array.h
+++ b/include/array.h
@@ -34,12 +34,12 @@ _mlib_array_hdr(void *p, ptrdiff_t align)
#define array_push(p, x) \
do { \
- _mlib_arr_hdr_t *hdr = _mlib_array_hdr(*(p), alignof(typeof(**(p)))); \
+ _mlib_arr_hdr_t *hdr = _mlib_array_hdr((p), alignof(typeof(*(p)))); \
if (hdr->len == hdr->cap) { \
- *(p) = array_resz(*(p), hdr->len * 2); \
- hdr = _mlib_array_hdr(*(p), alignof(typeof(**(p)))); \
+ (p) = array_resz((p), hdr->len * 2); \
+ hdr = _mlib_array_hdr((p), alignof(typeof(*(p)))); \
} \
- (*(p))[hdr->len++] = (x); \
+ (p)[hdr->len++] = (x); \
} while (false)
#define array_extend(p, xs, n) \
diff --git a/test/_brk-test.h b/test/_brk-test.h
index 40098c3..6e0c502 100644
--- a/test/_brk-test.h
+++ b/test/_brk-test.h
@@ -73,7 +73,7 @@ test(u8view_t sv, int id)
total += w;
if (op == U'÷')
- array_push(&items, array_new(mem, char8_t, 64));
+ array_push(items, array_new(mem, char8_t, 64));
array_extend(items[array_len(items) - 1], buf, w);
}
diff --git a/test/_norm-test.h b/test/_norm-test.h
index e4da609..4083e1a 100644
--- a/test/_norm-test.h
+++ b/test/_norm-test.h
@@ -73,7 +73,7 @@ test(u8view_t sv, int id)
array_extend(s, buf, w);
} while (_ != MBEND);
- array_push(&columns, ((u8view_t){s, array_len(s)}));
+ array_push(columns, ((u8view_t){s, array_len(s)}));
}
for (size_t i = 0; i < 5; i++) {
diff --git a/test/array-test.c b/test/array-test.c
index 3eb955a..307dd9a 100644
--- a/test/array-test.c
+++ b/test/array-test.c
@@ -37,7 +37,7 @@ main(int, char **argv)
array_hdr(xs)->len = 4;
for (int i = 4; i < 69; i++) {
- array_push(&xs, i + 1);
+ array_push(xs, i + 1);
if (stdc_count_ones((unsigned)i) == 1) {
/* Integers don’t need padding. It simplifies the test */
if ((size_t)ctx.last_alloc_size
diff --git a/test/wbrk-human-test.c b/test/wbrk-human-test.c
index 45dcaef..4536afa 100644
--- a/test/wbrk-human-test.c
+++ b/test/wbrk-human-test.c
@@ -56,9 +56,9 @@ test(u8view_t sv, int id)
u8view_t *ws = array_new(mem, typeof(*ws), 64);
while (ucscut(&w, &sv, U"|", 1) != MBEND)
- array_push(&ws, w);
+ array_push(ws, w);
if (w.len > 0)
- array_push(&ws, w);
+ array_push(ws, w);
/* Assert the word count is correct */
size_t n;