aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/kstd/src/libc/string.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/libs/kstd/src/libc/string.cpp b/libs/kstd/src/libc/string.cpp
index 319f6fd..b7d4c6b 100644
--- a/libs/kstd/src/libc/string.cpp
+++ b/libs/kstd/src/libc/string.cpp
@@ -27,6 +27,27 @@ namespace kstd::libc
return std::bit_cast<char>(*mismatched.in1) - std::bit_cast<char>(*mismatched.in2);
}
+
+ auto memmove(void * dest, void const * src, std::size_t size) -> void *
+ {
+ auto dest_span = std::span{static_cast<std::byte *>(dest), size};
+ auto src_span = std::span{static_cast<std::byte const *>(src), size};
+ if (dest < src)
+ {
+ for (std::size_t i = 0; i < size; ++i)
+ {
+ dest_span[i] = src_span[i];
+ }
+ }
+ else
+ {
+ for (std::size_t i = size; i > 0; --i)
+ {
+ dest_span[i - 1] = src_span[i - 1];
+ }
+ }
+ return dest;
+ }
}
} // namespace kstd::libc \ No newline at end of file