From 3d2a2a58c11fa6b7653a0f77de9aa1f7cdb1921a Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 21 Dec 2025 19:10:19 -0500 Subject: usr: sdk: Add memcpy() function Signed-off-by: Ian Moffett --- usr/sdk/common/string/memcpy.c | 20 ++++++++++++++++++++ usr/sdk/inc/sdk/string.h | 12 ++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 usr/sdk/common/string/memcpy.c 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 + +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_ */ -- cgit v1.2.3