summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-12-21 19:10:19 -0500
committerIan Moffett <ian@osmora.org>2025-12-21 19:10:19 -0500
commit3d2a2a58c11fa6b7653a0f77de9aa1f7cdb1921a (patch)
tree73be80da6920ff5d354e6d620aa09d28d2a88945
parent085f9b4de880efef92ae5a678c16fa8f05c8a579 (diff)
usr: sdk: Add memcpy() function
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--usr/sdk/common/string/memcpy.c20
-rw-r--r--usr/sdk/inc/sdk/string.h12
2 files changed, 32 insertions, 0 deletions
diff --git a/usr/sdk/common/string/memcpy.c b/usr/sdk/common/string/memcpy.c
new file mode 100644
index 0000000..5470f5d
--- /dev/null
+++ b/usr/sdk/common/string/memcpy.c
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025, Ian Moffett.
+ * Provided under the BSD-3 clause.
+ */
+
+#include <sdk/string.h>
+
+void *
+memcpy(void *dest, const void *src, USIZE count)
+{
+ if (dest == NULL || src == NULL) {
+ return NULL;
+ }
+
+ for (USIZE i = 0; i < count; ++i) {
+ ((char *)dest)[i] = ((char *)src)[i];
+ }
+
+ return dest;
+}
diff --git a/usr/sdk/inc/sdk/string.h b/usr/sdk/inc/sdk/string.h
index f7668fd..36261d0 100644
--- a/usr/sdk/inc/sdk/string.h
+++ b/usr/sdk/inc/sdk/string.h
@@ -15,4 +15,16 @@
*/
USIZE strlen(const char *str);
+/*
+ * Copy a variable number of bytes from one memory location
+ * to another.
+ *
+ * @dest: Destination buffer
+ * @src: Source buffer
+ * @count: Byte count
+ *
+ * Returns the base of `dest' on success
+ */
+void *memcpy(void *dest, const void *src, USIZE count);
+
#endif /* !_SDK_STRING_H_ */