return pgsz;
}
-bool memeqbyte(uint8_t byte, const void *data, size_t length) {
- /* Does the buffer consist entirely of the same specific byte value?
- * Copied from https://github.com/systemd/casync/, copied in turn from
- * https://github.com/rustyrussell/ccan/blob/master/ccan/mem/mem.c#L92,
- * which is licensed CC-0.
- */
-
- const uint8_t *p = data;
-
- /* Check first 16 bytes manually */
- for (size_t i = 0; i < 16; i++, length--) {
- if (length == 0)
- return true;
- if (p[i] != byte)
- return false;
- }
-
- /* Now we know first 16 bytes match, memcmp() with self. */
- return memcmp(data, p + 16, length) == 0;
-}
-
void* memdup_reverse(const void *mem, size_t size) {
assert(mem);
assert(size != 0);
#define zero(x) (memzero(&(x), sizeof(x)))
-bool memeqbyte(uint8_t byte, const void *data, size_t length) _nonnull_if_nonzero_(2, 3);
-
-#define memeqzero(data, length) memeqbyte(0x00, data, length)
-
-#define eqzero(x) memeqzero(x, sizeof(x))
-
static inline void* mempset(void *s, int c, size_t n) {
memset(s, c, n);
return (uint8_t*) s + n;
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include "memory-util-fundamental.h"
+
+bool memeqbyte(uint8_t byte, const void *data, size_t length) {
+ /* Does the buffer consist entirely of the same specific byte value?
+ * Copied from https://github.com/systemd/casync/, copied in turn from
+ * https://github.com/rustyrussell/ccan/blob/master/ccan/mem/mem.c#L92,
+ * which is licensed CC-0.
+ */
+
+ const uint8_t *p = data;
+
+ /* Check first 16 bytes manually */
+ for (size_t i = 0; i < 16; i++, length--) {
+ if (length == 0)
+ return true;
+ if (p[i] != byte)
+ return false;
+ }
+
+ /* Now we know first 16 bytes match, memcmp() with self. */
+ return memcmp(data, p + 16, length) == 0;
+}
# include <string.h>
#endif
-#include "assert-fundamental.h"
-#include "cleanup-fundamental.h"
+#include "assert-fundamental.h" /* IWYU pragma: keep */
#include "macro-fundamental.h"
#define memzero(x, l) \
assert(((uintptr_t) _p) % alignof(t) == 0); \
(t *) _p; \
})
+
+bool memeqbyte(uint8_t byte, const void *data, size_t length) _nonnull_if_nonzero_(2, 3);
+#define memeqzero(data, length) memeqbyte(0x00, data, length)
+#define eqzero(x) memeqzero(x, sizeof(x))
'edid-fundamental.c',
'efivars-fundamental.c',
'iovec-util-fundamental.h',
+ 'memory-util-fundamental.c',
'sha1-fundamental.c',
'sha256-fundamental.c',
'string-util-fundamental.c',