From f8797c7eb33986fe95f54dafc8467a64ce7a52af Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 16:10:50 +0000 Subject: [PATCH 1/6] Initial plan From 5f47dfb1a1854ef757b9b646536ea34ad5bb609e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 16:19:30 +0000 Subject: [PATCH 2/6] Remove using namespace std from kf namespace and add std:: prefixes Co-authored-by: SergiusTheBest <4660722+SergiusTheBest@users.noreply.github.com> --- include/kf/ASimpleString.h | 9 ++++----- include/kf/ArrayUtils.h | 1 - include/kf/Base64.h | 1 - include/kf/EarlyAllocator.h | 17 ++++++++--------- include/kf/EncodingDetector.h | 3 +-- include/kf/Hex.h | 11 +++++------ include/kf/Scanner.h | 5 ++--- include/kf/TextDetector.h | 9 ++++----- include/kf/USimpleString.h | 15 +++++++-------- include/kf/ext/timsort.h | 9 ++++----- 10 files changed, 35 insertions(+), 45 deletions(-) diff --git a/include/kf/ASimpleString.h b/include/kf/ASimpleString.h index be7c845..116bbdc 100644 --- a/include/kf/ASimpleString.h +++ b/include/kf/ASimpleString.h @@ -5,7 +5,6 @@ namespace kf { - using namespace std; /////////////////////////////////////////////////////////////////////////////////////////////////// // ASimpleString - non-owning string for NT kernel, inspired by http://docs.oracle.com/javase/7/docs/api/java/lang/String.html @@ -16,8 +15,8 @@ namespace kf public: ASimpleString(); - template - ASimpleString(span buffer); + template + ASimpleString(std::span buffer); ASimpleString(_In_ const ANSI_STRING& str) { @@ -184,8 +183,8 @@ namespace kf empty(); } - template - inline ASimpleString::ASimpleString(span buffer) + template + inline ASimpleString::ASimpleString(std::span buffer) { setString(const_cast(reinterpret_cast(buffer.data())), static_cast(buffer.size_bytes())); } diff --git a/include/kf/ArrayUtils.h b/include/kf/ArrayUtils.h index 5a95894..4801e10 100644 --- a/include/kf/ArrayUtils.h +++ b/include/kf/ArrayUtils.h @@ -3,7 +3,6 @@ namespace kf { - using namespace std; template inline constexpr std::array makeArrayOfBytes(Ts&&... args) noexcept diff --git a/include/kf/Base64.h b/include/kf/Base64.h index f9317c1..53310fd 100644 --- a/include/kf/Base64.h +++ b/include/kf/Base64.h @@ -4,7 +4,6 @@ namespace kf { - using namespace std; // original implementation is taken from https://github.com/adamvr/arduino-base64/blob/master/Base64.cpp diff --git a/include/kf/EarlyAllocator.h b/include/kf/EarlyAllocator.h index ff5a5ec..5708cb9 100644 --- a/include/kf/EarlyAllocator.h +++ b/include/kf/EarlyAllocator.h @@ -2,18 +2,17 @@ namespace kf { - using namespace std; template class EarlyAllocator { public: - static_assert(!is_const_v, "The C++ Standard forbids containers of const elements because allocator is ill-formed."); + static_assert(!std::is_const_v, "The C++ Standard forbids containers of const elements because allocator is ill-formed."); using value_type = T; - using size_type = size_t; - using difference_type = ptrdiff_t; - using propagate_on_container_move_assignment = true_type; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + using propagate_on_container_move_assignment = std::true_type; constexpr EarlyAllocator() noexcept = default; @@ -31,7 +30,7 @@ namespace kf EarlyAllocator& operator=(const EarlyAllocator&) noexcept = default; template - T* initialize(const size_t count) noexcept + T* initialize(const std::size_t count) noexcept { if (m_ptr || m_size) { @@ -44,7 +43,7 @@ namespace kf return m_ptr; } - void deallocate(const T* ptr, const size_t count) noexcept + void deallocate(const T* ptr, const std::size_t count) noexcept { if (ptr != m_ptr || count * sizeof(T) > m_size) { @@ -56,7 +55,7 @@ namespace kf m_size = 0; } - _NODISCARD T* allocate(const size_t count) noexcept + _NODISCARD T* allocate(const std::size_t count) noexcept { if (!m_ptr || count * sizeof(T) > m_size) { @@ -68,6 +67,6 @@ namespace kf private: T* m_ptr = nullptr; - size_t m_size = 0; + std::size_t m_size = 0; }; } diff --git a/include/kf/EncodingDetector.h b/include/kf/EncodingDetector.h index 0051dc6..6249892 100644 --- a/include/kf/EncodingDetector.h +++ b/include/kf/EncodingDetector.h @@ -4,7 +4,6 @@ namespace kf { - using namespace std; ////////////////////////////////////////////////////////////////////////////////// // EncodingDetector class identifies the encoding of a buffer. @@ -106,7 +105,7 @@ namespace kf { int zeros[2] = {}; - for (size_t i = 0; i < buffer.size(); ++i) + for (std::size_t i = 0; i < buffer.size(); ++i) { if (buffer[i] == std::byte(0)) { diff --git a/include/kf/Hex.h b/include/kf/Hex.h index aa0ec1a..c8235ba 100644 --- a/include/kf/Hex.h +++ b/include/kf/Hex.h @@ -6,7 +6,6 @@ namespace kf { - using namespace std; //////////////////////////////////////////////////////////////////////////// // The Hex class provides functionality to encode binary data into hexadecimal string representation @@ -40,7 +39,7 @@ namespace kf return true; } - static int decodeLen(span input) + static int decodeLen(std::span input) { return static_cast(input.size() / 2); } @@ -52,7 +51,7 @@ namespace kf static bool decode(const ASimpleString& input, _Out_ span& output) { - if (output.size() != static_cast(decodeLen(input))) + if (output.size() != static_cast(decodeLen(input))) { return false; } @@ -74,14 +73,14 @@ namespace kf private: static inline const char kHexArray[] = "0123456789ABCDEF"; - static array toHex(uint8_t b) + static std::array toHex(uint8_t b) { return { static_cast(kHexArray[b >> 4]), static_cast(kHexArray[b & 0xF]) }; } - static int fromHex(const array& hexByte) + static int fromHex(const std::array& hexByte) { - array digits; + std::array digits; for (int i = 0; i < 2; ++i) { diff --git a/include/kf/Scanner.h b/include/kf/Scanner.h index ce4ff39..dcf276c 100644 --- a/include/kf/Scanner.h +++ b/include/kf/Scanner.h @@ -5,7 +5,6 @@ namespace kf { - using namespace std; class Scanner { @@ -44,7 +43,7 @@ namespace kf { auto data = span_cast(m_data); - ptrdiff_t fromIndex = 0; + std::ptrdiff_t fromIndex = 0; const auto str = split(data, L'\n', fromIndex); skip(static_cast(fromIndex > 0 ? fromIndex * sizeof(wchar_t) : m_data.size())); @@ -56,7 +55,7 @@ namespace kf { auto data = span_cast(m_data); - ptrdiff_t fromIndex = 0; + std::ptrdiff_t fromIndex = 0; const auto str = split(data, '\n', fromIndex); skip(static_cast(fromIndex > 0 ? fromIndex * sizeof(char) : m_data.size())); diff --git a/include/kf/TextDetector.h b/include/kf/TextDetector.h index 3e16a74..3b15a06 100644 --- a/include/kf/TextDetector.h +++ b/include/kf/TextDetector.h @@ -7,7 +7,6 @@ namespace kf { - using namespace std; /////////////////////////////////////////////////////////////////////////////////////////////////// // TextDetector class provides a utility to determine whether a given buffer contains textual data. @@ -62,15 +61,15 @@ namespace kf } template - static bool isValidTextLE(span buffer) + static bool isValidTextLE(std::span buffer) { - return ranges::none_of(buffer, [](auto ch) { return isInvalidChar(ch); }); + return std::ranges::none_of(buffer, [](auto ch) { return isInvalidChar(ch); }); } template - static bool isValidTextBE(span buffer) + static bool isValidTextBE(std::span buffer) { - return ranges::none_of(buffer, [](auto ch) { return isInvalidChar(swapBytes(ch)); }); + return std::ranges::none_of(buffer, [](auto ch) { return isInvalidChar(swapBytes(ch)); }); } }; } diff --git a/include/kf/USimpleString.h b/include/kf/USimpleString.h index 86cc71e..4ef3a55 100644 --- a/include/kf/USimpleString.h +++ b/include/kf/USimpleString.h @@ -5,7 +5,6 @@ namespace kf { - using namespace std; /////////////////////////////////////////////////////////////////////////////////////////////////// // USimpleString - non-owning string for NT kernel, inspired by http://docs.oracle.com/javase/7/docs/api/java/lang/String.html @@ -20,8 +19,8 @@ namespace kf USimpleString(_In_ const UNICODE_STRING& str); USimpleString(_In_reads_bytes_(byteLength) const void* buffer, _In_ int byteLength); - template - USimpleString(span buffer); + template + USimpleString(std::span buffer); USimpleString(_Inout_ USimpleString&& another); USimpleString(_In_ const USimpleString& another); @@ -118,7 +117,7 @@ namespace kf return ::RtlAppendUnicodeToString(&m_str, str); } - template + template int copyTo(_Out_ WCHAR(&destination)[N]) const { return copyTo(N, destination); @@ -126,7 +125,7 @@ namespace kf int copyTo(_In_ int maxCharLength, _Out_cap_(maxCharLength) WCHAR* destination) const { - const int charsToCopy = min(maxCharLength - 1, charLength()); + const int charsToCopy = std::min(maxCharLength - 1, charLength()); if (charsToCopy >= 0) { @@ -184,7 +183,7 @@ namespace kf inline USimpleString::USimpleString(_In_ const WCHAR* str, _In_ int maxCharLength) { - size_t byteLength = 0; + std::size_t byteLength = 0; ::RtlStringCbLengthW(str, maxCharLength * sizeof(WCHAR), &byteLength); setString(const_cast(str), static_cast(byteLength), maxCharLength * sizeof(WCHAR)); } @@ -199,8 +198,8 @@ namespace kf setString(const_cast(buffer), byteLength); } - template - inline USimpleString::USimpleString(span buffer) + template + inline USimpleString::USimpleString(std::span buffer) { setString(const_cast(reinterpret_cast(buffer.data())), static_cast(buffer.size_bytes())); } diff --git a/include/kf/ext/timsort.h b/include/kf/ext/timsort.h index 12963ad..5239ad8 100644 --- a/include/kf/ext/timsort.h +++ b/include/kf/ext/timsort.h @@ -38,7 +38,6 @@ namespace timsort { namespace detail { - using namespace std; template inline int cmp(const T& lhs, const T& rhs) @@ -101,7 +100,7 @@ namespace timsort inline int compute_minrun(const uint64_t size) { const int top_bit = 64 - clzll(size); - const int shift = max(top_bit, 6) - 6; + const int shift = std::max(top_bit, 6) - 6; const int minrun = static_cast(size >> shift); const uint64_t mask = (1ULL << shift) - 1; @@ -218,7 +217,7 @@ namespace timsort return; } - swap(dst[start], dst[end]); + std::swap(dst[start], dst[end]); start++; end--; } @@ -238,7 +237,7 @@ namespace timsort { if (cmp(dst[size - 2], dst[size - 1]) > 0) { - swap(dst[size - 2], dst[size - 1]); + std::swap(dst[size - 2], dst[size - 1]); } return 2; @@ -350,7 +349,7 @@ namespace timsort const size_t B = stack[stack_curr - 1].length; const size_t curr = stack[stack_curr - 2].start; size_t i, j, k; - tim_sort_resize(store, min(A, B)); + tim_sort_resize(store, std::min(A, B)); T* storage = store->storage; /* left merge */ From bae8cd11e49b365981faf9120f8563628536ed60 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 16:21:16 +0000 Subject: [PATCH 3/6] Final: All using namespace std removed from kf namespace Co-authored-by: SergiusTheBest <4660722+SergiusTheBest@users.noreply.github.com> --- _codeql_detected_source_root | 1 + 1 file changed, 1 insertion(+) create mode 120000 _codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/_codeql_detected_source_root @@ -0,0 +1 @@ +. \ No newline at end of file From e121bda92df9856f712b48329ff1aaaba404c6bc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 16:41:04 +0000 Subject: [PATCH 4/6] Use (std::min)/(std::max) macro-safe syntax and remove std:: from size_t/ptrdiff_t Co-authored-by: SergiusTheBest <4660722+SergiusTheBest@users.noreply.github.com> --- include/kf/ASimpleString.h | 4 ++-- include/kf/EarlyAllocator.h | 12 ++++++------ include/kf/EncodingDetector.h | 2 +- include/kf/Hex.h | 2 +- include/kf/Scanner.h | 4 ++-- include/kf/USimpleString.h | 10 +++++----- include/kf/ext/timsort.h | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/kf/ASimpleString.h b/include/kf/ASimpleString.h index 116bbdc..e5de679 100644 --- a/include/kf/ASimpleString.h +++ b/include/kf/ASimpleString.h @@ -15,7 +15,7 @@ namespace kf public: ASimpleString(); - template + template ASimpleString(std::span buffer); ASimpleString(_In_ const ANSI_STRING& str) @@ -183,7 +183,7 @@ namespace kf empty(); } - template + template inline ASimpleString::ASimpleString(std::span buffer) { setString(const_cast(reinterpret_cast(buffer.data())), static_cast(buffer.size_bytes())); diff --git a/include/kf/EarlyAllocator.h b/include/kf/EarlyAllocator.h index 5708cb9..9787cb2 100644 --- a/include/kf/EarlyAllocator.h +++ b/include/kf/EarlyAllocator.h @@ -10,8 +10,8 @@ namespace kf static_assert(!std::is_const_v, "The C++ Standard forbids containers of const elements because allocator is ill-formed."); using value_type = T; - using size_type = std::size_t; - using difference_type = std::ptrdiff_t; + using size_type = size_t; + using difference_type = ptrdiff_t; using propagate_on_container_move_assignment = std::true_type; constexpr EarlyAllocator() noexcept = default; @@ -30,7 +30,7 @@ namespace kf EarlyAllocator& operator=(const EarlyAllocator&) noexcept = default; template - T* initialize(const std::size_t count) noexcept + T* initialize(const size_t count) noexcept { if (m_ptr || m_size) { @@ -43,7 +43,7 @@ namespace kf return m_ptr; } - void deallocate(const T* ptr, const std::size_t count) noexcept + void deallocate(const T* ptr, const size_t count) noexcept { if (ptr != m_ptr || count * sizeof(T) > m_size) { @@ -55,7 +55,7 @@ namespace kf m_size = 0; } - _NODISCARD T* allocate(const std::size_t count) noexcept + _NODISCARD T* allocate(const size_t count) noexcept { if (!m_ptr || count * sizeof(T) > m_size) { @@ -67,6 +67,6 @@ namespace kf private: T* m_ptr = nullptr; - std::size_t m_size = 0; + size_t m_size = 0; }; } diff --git a/include/kf/EncodingDetector.h b/include/kf/EncodingDetector.h index 6249892..dfff96a 100644 --- a/include/kf/EncodingDetector.h +++ b/include/kf/EncodingDetector.h @@ -105,7 +105,7 @@ namespace kf { int zeros[2] = {}; - for (std::size_t i = 0; i < buffer.size(); ++i) + for (size_t i = 0; i < buffer.size(); ++i) { if (buffer[i] == std::byte(0)) { diff --git a/include/kf/Hex.h b/include/kf/Hex.h index c8235ba..da5eb24 100644 --- a/include/kf/Hex.h +++ b/include/kf/Hex.h @@ -51,7 +51,7 @@ namespace kf static bool decode(const ASimpleString& input, _Out_ span& output) { - if (output.size() != static_cast(decodeLen(input))) + if (output.size() != static_cast(decodeLen(input))) { return false; } diff --git a/include/kf/Scanner.h b/include/kf/Scanner.h index dcf276c..9e93956 100644 --- a/include/kf/Scanner.h +++ b/include/kf/Scanner.h @@ -43,7 +43,7 @@ namespace kf { auto data = span_cast(m_data); - std::ptrdiff_t fromIndex = 0; + ptrdiff_t fromIndex = 0; const auto str = split(data, L'\n', fromIndex); skip(static_cast(fromIndex > 0 ? fromIndex * sizeof(wchar_t) : m_data.size())); @@ -55,7 +55,7 @@ namespace kf { auto data = span_cast(m_data); - std::ptrdiff_t fromIndex = 0; + ptrdiff_t fromIndex = 0; const auto str = split(data, '\n', fromIndex); skip(static_cast(fromIndex > 0 ? fromIndex * sizeof(char) : m_data.size())); diff --git a/include/kf/USimpleString.h b/include/kf/USimpleString.h index 4ef3a55..70a15d8 100644 --- a/include/kf/USimpleString.h +++ b/include/kf/USimpleString.h @@ -19,7 +19,7 @@ namespace kf USimpleString(_In_ const UNICODE_STRING& str); USimpleString(_In_reads_bytes_(byteLength) const void* buffer, _In_ int byteLength); - template + template USimpleString(std::span buffer); USimpleString(_Inout_ USimpleString&& another); @@ -117,7 +117,7 @@ namespace kf return ::RtlAppendUnicodeToString(&m_str, str); } - template + template int copyTo(_Out_ WCHAR(&destination)[N]) const { return copyTo(N, destination); @@ -125,7 +125,7 @@ namespace kf int copyTo(_In_ int maxCharLength, _Out_cap_(maxCharLength) WCHAR* destination) const { - const int charsToCopy = std::min(maxCharLength - 1, charLength()); + const int charsToCopy = (std::min)(maxCharLength - 1, charLength()); if (charsToCopy >= 0) { @@ -183,7 +183,7 @@ namespace kf inline USimpleString::USimpleString(_In_ const WCHAR* str, _In_ int maxCharLength) { - std::size_t byteLength = 0; + size_t byteLength = 0; ::RtlStringCbLengthW(str, maxCharLength * sizeof(WCHAR), &byteLength); setString(const_cast(str), static_cast(byteLength), maxCharLength * sizeof(WCHAR)); } @@ -198,7 +198,7 @@ namespace kf setString(const_cast(buffer), byteLength); } - template + template inline USimpleString::USimpleString(std::span buffer) { setString(const_cast(reinterpret_cast(buffer.data())), static_cast(buffer.size_bytes())); diff --git a/include/kf/ext/timsort.h b/include/kf/ext/timsort.h index 5239ad8..6a11c7d 100644 --- a/include/kf/ext/timsort.h +++ b/include/kf/ext/timsort.h @@ -100,7 +100,7 @@ namespace timsort inline int compute_minrun(const uint64_t size) { const int top_bit = 64 - clzll(size); - const int shift = std::max(top_bit, 6) - 6; + const int shift = (std::max)(top_bit, 6) - 6; const int minrun = static_cast(size >> shift); const uint64_t mask = (1ULL << shift) - 1; @@ -349,7 +349,7 @@ namespace timsort const size_t B = stack[stack_curr - 1].length; const size_t curr = stack[stack_curr - 2].start; size_t i, j, k; - tim_sort_resize(store, std::min(A, B)); + tim_sort_resize(store, (std::min)(A, B)); T* storage = store->storage; /* left merge */ From f33d6f40ab7c87dc116efb74bdd0095c17c19ad4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 16:59:36 +0000 Subject: [PATCH 5/6] Fix build errors: add std:: prefix to span in function signatures Co-authored-by: SergiusTheBest <4660722+SergiusTheBest@users.noreply.github.com> --- include/kf/Base64.h | 2 +- include/kf/EncodingDetector.h | 12 ++++++------ include/kf/Hex.h | 4 ++-- include/kf/Scanner.h | 4 ++-- include/kf/TextDetector.h | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/kf/Base64.h b/include/kf/Base64.h index 53310fd..dd93c4d 100644 --- a/include/kf/Base64.h +++ b/include/kf/Base64.h @@ -32,7 +32,7 @@ namespace kf return ((6 * input.charLength()) / 8) - numEq; } - static int decode(const USimpleString& input, span output) + static int decode(const USimpleString& input, std::span output) { int inputIdx = 0; int a4Idx = 0; diff --git a/include/kf/EncodingDetector.h b/include/kf/EncodingDetector.h index dfff96a..cea28a9 100644 --- a/include/kf/EncodingDetector.h +++ b/include/kf/EncodingDetector.h @@ -12,7 +12,7 @@ namespace kf class EncodingDetector { public: - EncodingDetector(span buffer); + EncodingDetector(std::span buffer); enum Encoding { @@ -32,15 +32,15 @@ namespace kf enum { kMinimalBufferSize = kMaximumBomLength }; private: - bool detectBom(span bomBytes); - bool detectUtf16(span buffer); + bool detectBom(std::span bomBytes); + bool detectUtf16(std::span buffer); private: Encoding m_encoding = Unknown; int m_bomLength = 0; }; - inline EncodingDetector::EncodingDetector(span buffer) : m_encoding(), m_bomLength() + inline EncodingDetector::EncodingDetector(std::span buffer) : m_encoding(), m_bomLength() { if (buffer.size() < kMinimalBufferSize) { @@ -61,7 +61,7 @@ namespace kf m_encoding = ANSI; } - inline bool EncodingDetector::detectBom(span bomBytes) + inline bool EncodingDetector::detectBom(std::span bomBytes) { if (bomBytes[0] == std::byte(0xff) && bomBytes[1] == std::byte(0xfe) && (bomBytes[2] != std::byte(0) || bomBytes[3] != std::byte(0))) { @@ -101,7 +101,7 @@ namespace kf return false; } - inline bool EncodingDetector::detectUtf16(span buffer) + inline bool EncodingDetector::detectUtf16(std::span buffer) { int zeros[2] = {}; diff --git a/include/kf/Hex.h b/include/kf/Hex.h index da5eb24..4895c02 100644 --- a/include/kf/Hex.h +++ b/include/kf/Hex.h @@ -13,12 +13,12 @@ namespace kf class Hex { public: - static int encodeLen(span input) + static int encodeLen(std::span input) { return static_cast(input.size() * 2); } - static bool encode(span input, _Out_ USimpleString& output) + static bool encode(std::span input, _Out_ USimpleString& output) { if (output.maxByteLength() < encodeLen(input)) { diff --git a/include/kf/Scanner.h b/include/kf/Scanner.h index 9e93956..a641171 100644 --- a/include/kf/Scanner.h +++ b/include/kf/Scanner.h @@ -9,7 +9,7 @@ namespace kf class Scanner { public: - Scanner(span data) : m_data(data) + Scanner(std::span data) : m_data(data) { } @@ -69,6 +69,6 @@ namespace kf } private: - span m_data; + std::span m_data; }; } diff --git a/include/kf/TextDetector.h b/include/kf/TextDetector.h index 3b15a06..b959b0f 100644 --- a/include/kf/TextDetector.h +++ b/include/kf/TextDetector.h @@ -15,7 +15,7 @@ namespace kf class TextDetector { public: - static bool isText(span buffer) + static bool isText(std::span buffer) { EncodingDetector encodingDetector(buffer); From 8f35d1ab627347057d44cb34f35141858511c4b2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 17:08:01 +0000 Subject: [PATCH 6/6] Fix remaining build errors: add std:: to span in Hex.h and replace _Xinvalid_argument with ASSERT Co-authored-by: SergiusTheBest <4660722+SergiusTheBest@users.noreply.github.com> --- include/kf/EarlyAllocator.h | 15 +++------------ include/kf/Hex.h | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/include/kf/EarlyAllocator.h b/include/kf/EarlyAllocator.h index 9787cb2..9542d6e 100644 --- a/include/kf/EarlyAllocator.h +++ b/include/kf/EarlyAllocator.h @@ -32,10 +32,7 @@ namespace kf template T* initialize(const size_t count) noexcept { - if (m_ptr || m_size) - { - _Xinvalid_argument("m_ptr || m_size"); - } + ASSERT(!(m_ptr || m_size)); m_size = count * sizeof(T); m_ptr = static_cast(operator new(m_size, poolType)); @@ -45,10 +42,7 @@ namespace kf void deallocate(const T* ptr, const size_t count) noexcept { - if (ptr != m_ptr || count * sizeof(T) > m_size) - { - _Xinvalid_argument("ptr != m_ptr || count * sizeof(T) > m_size"); - } + ASSERT(ptr == m_ptr && count * sizeof(T) <= m_size); operator delete(m_ptr); m_ptr = nullptr; @@ -57,10 +51,7 @@ namespace kf _NODISCARD T* allocate(const size_t count) noexcept { - if (!m_ptr || count * sizeof(T) > m_size) - { - _Xinvalid_argument("!m_ptr || count * sizeof(T) > m_size"); - } + ASSERT(m_ptr && count * sizeof(T) <= m_size); return m_ptr; } diff --git a/include/kf/Hex.h b/include/kf/Hex.h index 4895c02..4aedc8b 100644 --- a/include/kf/Hex.h +++ b/include/kf/Hex.h @@ -49,7 +49,7 @@ namespace kf return input.charLength() / 2; } - static bool decode(const ASimpleString& input, _Out_ span& output) + static bool decode(const ASimpleString& input, _Out_ std::span& output) { if (output.size() != static_cast(decodeLen(input))) {