From f26c0d00df97c3b3ffce1047e92acfcbc680845b Mon Sep 17 00:00:00 2001 From: Uzair Nawaz Date: Thu, 24 Jul 2025 11:29:40 -0700 Subject: [libc] Implemented wcsdup libc function (#150453) Implemented wcsdup by templating internal strdup function --- libc/src/string/allocating_string_utils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libc/src/string') diff --git a/libc/src/string/allocating_string_utils.h b/libc/src/string/allocating_string_utils.h index 1dece510e796..e2f61f77b0c7 100644 --- a/libc/src/string/allocating_string_utils.h +++ b/libc/src/string/allocating_string_utils.h @@ -20,15 +20,15 @@ namespace LIBC_NAMESPACE_DECL { namespace internal { -LIBC_INLINE cpp::optional strdup(const char *src) { +template LIBC_INLINE cpp::optional strdup(const T *src) { if (src == nullptr) return cpp::nullopt; size_t len = string_length(src) + 1; AllocChecker ac; - char *newstr = new (ac) char[len]; + T *newstr = new (ac) T[len]; if (!ac) return cpp::nullopt; - inline_memcpy(newstr, src, len); + inline_memcpy(newstr, src, len * sizeof(T)); return newstr; } -- cgit v1.2.3