aboutsummaryrefslogtreecommitdiff
path: root/libc/src/string
diff options
context:
space:
mode:
Diffstat (limited to 'libc/src/string')
-rw-r--r--libc/src/string/CMakeLists.txt1
-rw-r--r--libc/src/string/allocating_string_utils.h6
-rw-r--r--libc/src/string/memory_utils/CMakeLists.txt1
-rw-r--r--libc/src/string/memory_utils/op_generic.h3
-rw-r--r--libc/src/string/memory_utils/utils.h2
-rw-r--r--libc/src/string/memory_utils/x86_64/inline_memcpy.h2
-rw-r--r--libc/src/string/string_utils.h3
7 files changed, 9 insertions, 9 deletions
diff --git a/libc/src/string/CMakeLists.txt b/libc/src/string/CMakeLists.txt
index 8784bc3..809decf 100644
--- a/libc/src/string/CMakeLists.txt
+++ b/libc/src/string/CMakeLists.txt
@@ -17,6 +17,7 @@ add_header_library(
DEPENDS
libc.hdr.types.size_t
libc.hdr.limits_macros
+ libc.hdr.stdint_proxy
libc.src.__support.CPP.bitset
libc.src.__support.CPP.type_traits
libc.src.__support.common
diff --git a/libc/src/string/allocating_string_utils.h b/libc/src/string/allocating_string_utils.h
index 1dece51..e2f61f7 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;
}
diff --git a/libc/src/string/memory_utils/CMakeLists.txt b/libc/src/string/memory_utils/CMakeLists.txt
index 8ab1c9f..670db30 100644
--- a/libc/src/string/memory_utils/CMakeLists.txt
+++ b/libc/src/string/memory_utils/CMakeLists.txt
@@ -34,6 +34,7 @@ add_header_library(
x86_64/inline_memmove.h
x86_64/inline_memset.h
DEPENDS
+ libc.hdr.stdint_proxy
libc.src.__support.common
libc.src.__support.CPP.bit
libc.src.__support.CPP.cstddef
diff --git a/libc/src/string/memory_utils/op_generic.h b/libc/src/string/memory_utils/op_generic.h
index 9349cfdd..3760341 100644
--- a/libc/src/string/memory_utils/op_generic.h
+++ b/libc/src/string/memory_utils/op_generic.h
@@ -23,6 +23,7 @@
#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_GENERIC_H
#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_GENERIC_H
+#include "hdr/stdint_proxy.h"
#include "src/__support/CPP/array.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/common.h"
@@ -34,8 +35,6 @@
#include "src/string/memory_utils/op_builtin.h"
#include "src/string/memory_utils/utils.h"
-#include <stdint.h>
-
static_assert((UINTPTR_MAX == 4294967295U) ||
(UINTPTR_MAX == 18446744073709551615UL),
"We currently only support 32- or 64-bit platforms");
diff --git a/libc/src/string/memory_utils/utils.h b/libc/src/string/memory_utils/utils.h
index c08608c..0f9c9e3 100644
--- a/libc/src/string/memory_utils/utils.h
+++ b/libc/src/string/memory_utils/utils.h
@@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_UTILS_H
#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_UTILS_H
+#include "hdr/stdint_proxy.h" // intptr_t / uintptr_t / INT32_MAX / INT32_MIN
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/cstddef.h"
#include "src/__support/CPP/type_traits.h"
@@ -18,7 +19,6 @@
#include "src/__support/macros/properties/architectures.h"
#include <stddef.h> // size_t
-#include <stdint.h> // intptr_t / uintptr_t / INT32_MAX / INT32_MIN
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/string/memory_utils/x86_64/inline_memcpy.h b/libc/src/string/memory_utils/x86_64/inline_memcpy.h
index 68f64fb..bf3aa1f 100644
--- a/libc/src/string/memory_utils/x86_64/inline_memcpy.h
+++ b/libc/src/string/memory_utils/x86_64/inline_memcpy.h
@@ -8,6 +8,7 @@
#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_X86_64_INLINE_MEMCPY_H
#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_X86_64_INLINE_MEMCPY_H
+#include "hdr/stdint_proxy.h" // SIZE_MAX
#include "src/__support/macros/attributes.h" // LIBC_INLINE_VAR
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include "src/string/memory_utils/op_builtin.h"
@@ -15,7 +16,6 @@
#include "src/string/memory_utils/utils.h"
#include <stddef.h> // size_t
-#include <stdint.h> // SIZE_MAX
#ifdef LLVM_LIBC_MEMCPY_X86_USE_ONLY_REPMOVSB
#error LLVM_LIBC_MEMCPY_X86_USE_ONLY_REPMOVSB is deprecated use LIBC_COPT_MEMCPY_X86_USE_REPMOVSB_FROM_SIZE=0 instead.
diff --git a/libc/src/string/string_utils.h b/libc/src/string/string_utils.h
index 1231117..80e5783 100644
--- a/libc/src/string/string_utils.h
+++ b/libc/src/string/string_utils.h
@@ -15,14 +15,13 @@
#define LLVM_LIBC_SRC_STRING_STRING_UTILS_H
#include "hdr/limits_macros.h"
+#include "hdr/stdint_proxy.h" // uintptr_t
#include "hdr/types/size_t.h"
#include "src/__support/CPP/bitset.h"
#include "src/__support/CPP/type_traits.h" // cpp::is_same_v
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
-#include <stdint.h> // uintptr_t
-
namespace LIBC_NAMESPACE_DECL {
namespace internal {