From 0abfd8cf3d68bdadcb30b4ae0f19eb3a3c6b6e65 Mon Sep 17 00:00:00 2001 From: bumbread Date: Wed, 10 Aug 2022 13:58:13 +1100 Subject: [PATCH] On the second thought memmove was correct --- src/string.c | 1 - test/stuff.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/stuff.c diff --git a/src/string.c b/src/string.c index d4f20f7..b6dbf53 100644 --- a/src/string.c +++ b/src/string.c @@ -12,7 +12,6 @@ void *memcpy(void *restrict s1, const void *restrict s2, size_t n) { void *memmove(void *s1, const void *s2, size_t n) { u8* c1 = s1; const u8* c2 = s2; - // Note(bumbread): shouldn't this be backwards? if (c1 != c2) { if (c1 < c2) { // reverse copy diff --git a/test/stuff.c b/test/stuff.c new file mode 100644 index 0000000..bc872ad --- /dev/null +++ b/test/stuff.c @@ -0,0 +1,13 @@ + +#include +#include + + + +int main() { + char arr[] = "Bruh\0\0\0"; + printf("Before memmove: %s\n", &arr[0]); + memmove(arr+3, arr, 4); + printf("After memmove: %s\n", &arr[0]); + return 0; +}