summaryrefslogtreecommitdiffstats
path: root/src/basic/memory-util.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
commit78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch)
treef515d16b6efd858a9aeb5b0ef5d6f90bf288283d /src/basic/memory-util.c
parentAdding debian version 255.5-1. (diff)
downloadsystemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz
systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/basic/memory-util.c')
-rw-r--r--src/basic/memory-util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/basic/memory-util.c b/src/basic/memory-util.c
index fcedae2..ed6024f 100644
--- a/src/basic/memory-util.c
+++ b/src/basic/memory-util.c
@@ -39,3 +39,19 @@ bool memeqbyte(uint8_t byte, const void *data, size_t length) {
/* 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);
+
+ void *p = malloc(size);
+ if (!p)
+ return NULL;
+
+ uint8_t *p_dst = p;
+ const uint8_t *p_src = mem;
+ for (size_t i = 0, k = size; i < size; i++, k--)
+ p_dst[i] = p_src[k-1];
+
+ return p;
+}