diff options
Diffstat (limited to 'libc/src/string')
| -rw-r--r-- | libc/src/string/allocating_string_utils.h | 6 |
1 files changed, 3 insertions, 3 deletions
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<char *> strdup(const char *src) { +template <typename T> LIBC_INLINE cpp::optional<T *> 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; } |
