aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-12-17 19:30:55 +0100
committerMattias Andrée <maandree@kth.se>2023-12-17 19:30:55 +0100
commite74de6938b5e3c0da101d5bbb0866fda1e4a330d (patch)
tree4183403ed1bd8afd3bae2776cf654a4befedb862
parentUpdate VERSION_MINOR (diff)
downloadlibsimple-e74de6938b5e3c0da101d5bbb0866fda1e4a330d.tar.gz
libsimple-e74de6938b5e3c0da101d5bbb0866fda1e4a330d.tar.bz2
libsimple-e74de6938b5e3c0da101d5bbb0866fda1e4a330d.tar.xz
Fix libsimple_arrayset and libsimple_arraypset and add libsimple_arrayfill and libsimple_arraynull
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libsimple/array.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/libsimple/array.h b/libsimple/array.h
index b17966b..5530e24 100644
--- a/libsimple/array.h
+++ b/libsimple/array.h
@@ -111,13 +111,13 @@
#endif
-#define libsimple_arrayset(buf, item, n) libsimple_memsetelem(buf, item, (n) * sizeof *(buf))
+#define libsimple_arrayset(buf, item, n) libsimple_memsetelem(buf, item, sizeof *(buf), n)
#ifndef arrayset
# define arrayset(...) libsimple_arrayset(__VA_ARGS__)
#endif
-#define libsimple_arraypset(buf, item, n) libsimple_mempsetelem(buf, item, (n) * sizeof *(buf))
+#define libsimple_arraypset(buf, item, n) libsimple_mempsetelem(buf, item, sizeof *(buf), n)
#ifndef arraypset
# define arraypset(...) libsimple_arraypset(__VA_ARGS__)
#endif
@@ -163,3 +163,15 @@
#ifndef arrayreplace
# define arrayreplace(...) libsimple_arrayreplace(__VA_ARGS__)
#endif
+
+
+#define libsimple_arrayfill(buf, item) libsimple_memsetelem(buf, item, sizeof *(buf), sizeof (buf) / sizeof *(buf))
+#ifndef arrayfill
+# define arrayfill(...) libsimple_arrayfill(__VA_ARGS__)
+#endif
+
+
+#define libsimple_arraynull(buf) libsimple_memsetelem(buf, (void *)0, sizeof *(buf), sizeof (buf) / sizeof *(buf))
+#ifndef arraynull
+# define arraynull(...) libsimple_arraynull(__VA_ARGS__)
+#endif