From e8422002f84dc4313894a5b3136c44a9005081fd Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Sat, 2 Nov 2024 20:45:02 -0500 Subject: Allocator deallocate is void rather than returning FudStatus. --- include/fud_c_string.hpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'include/fud_c_string.hpp') diff --git a/include/fud_c_string.hpp b/include/fud_c_string.hpp index d55ba30..a1ab51a 100644 --- a/include/fud_c_string.hpp +++ b/include/fud_c_string.hpp @@ -20,14 +20,17 @@ #include #include +#include #include namespace fud { +constexpr ssize_t MAX_C_STRING_LENGTH = std::numeric_limits::max() - 1; + constexpr ssize_t cStringLength(const char* str, size_t maxLength) { - if (str == nullptr || maxLength > (SSIZE_MAX - 1)) { + if (str == nullptr || maxLength > MAX_C_STRING_LENGTH) { return -1; } @@ -46,13 +49,14 @@ constexpr ssize_t cStringLength(const char* str, size_t maxLength) constexpr ssize_t cStringLength(const char* str) { - constexpr auto maxLength = SSIZE_MAX - 1; - return cStringLength(str, maxLength); + return cStringLength(str, MAX_C_STRING_LENGTH); } constexpr ssize_t cStringLength(const char8_t* str, size_t maxLength) { - if (str == nullptr || maxLength > (SSIZE_MAX - 1)) { + // Cannot cast str to const char* without breaking constexpr + // return cStringLength(reinterpret_cast(str), maxLength); + if (str == nullptr || maxLength > MAX_C_STRING_LENGTH) { return -1; } @@ -71,8 +75,7 @@ constexpr ssize_t cStringLength(const char8_t* str, size_t maxLength) constexpr ssize_t cStringLength(const char8_t* str) { - constexpr auto maxLength = SSIZE_MAX - 1; - return cStringLength(str, maxLength); + return cStringLength(str, MAX_C_STRING_LENGTH); } } // namespace fud -- cgit v1.2.3