From b77a7516251d21aef1c6130dad116edff1a13173 Mon Sep 17 00:00:00 2001 From: rohitsutreja <128723626+rohitsutreja@users.noreply.github.com> Date: Fri, 10 Oct 2025 22:07:05 +0530 Subject: [PATCH 1/2] Revert std::malloc/std::free to global malloc/free (#4569) (#4570) --- include/fmt/format.h | 7 ++++--- include/fmt/std.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index c3a1bda0..a10470f2 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -41,10 +41,11 @@ #include "base.h" #ifndef FMT_MODULE +# include // malloc, free + # include // std::signbit # include // std::byte # include // uint32_t -# include // std::malloc, std::free # include // std::memcpy # include // std::numeric_limits # include // std::bad_alloc @@ -744,12 +745,12 @@ template struct allocator : private std::decay { auto allocate(size_t n) -> T* { FMT_ASSERT(n <= max_value() / sizeof(T), ""); - T* p = static_cast(std::malloc(n * sizeof(T))); + T* p = static_cast(malloc(n * sizeof(T))); if (!p) FMT_THROW(std::bad_alloc()); return p; } - void deallocate(T* p, size_t) { std::free(p); } + void deallocate(T* p, size_t) { free(p); } constexpr friend auto operator==(allocator, allocator) noexcept -> bool { return true; // All instances of this allocator are equivalent. diff --git a/include/fmt/std.h b/include/fmt/std.h index 0cc0066e..f12f14df 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -198,7 +198,7 @@ auto write_demangled_name(OutputIt out, const std::type_info& ti) -> OutputIt { int status = 0; size_t size = 0; std::unique_ptr demangled_name_ptr( - abi::__cxa_demangle(ti.name(), nullptr, &size, &status), &std::free); + abi::__cxa_demangle(ti.name(), nullptr, &size, &status), &free); string_view demangled_name_view; if (demangled_name_ptr) { From 1234bc312ec3f62f7b9bb80756bf4d6074949bfa Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 11 Oct 2025 07:56:24 -0700 Subject: [PATCH 2/2] Apply clang-tidy --- include/fmt/std.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/fmt/std.h b/include/fmt/std.h index f12f14df..1127feaa 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -139,8 +139,8 @@ template class is_variant_formattable { #endif // FMT_CPP_LIB_VARIANT #if FMT_USE_RTTI -inline string_view normalize_libcxx_inline_namespaces( - string_view demangled_name_view, char* begin) { +inline auto normalize_libcxx_inline_namespaces(string_view demangled_name_view, + char* begin) -> string_view { // Normalization of stdlib inline namespace names. // libc++ inline namespaces. // std::__1::* -> std::* @@ -211,7 +211,7 @@ auto write_demangled_name(OutputIt out, const std::type_info& ti) -> OutputIt { # elif FMT_MSC_VERSION && defined(_MSVC_STL_UPDATE) return normalize_msvc_abi_name(ti.name(), out); # elif FMT_MSC_VERSION && defined(_LIBCPP_VERSION) - const string_view demangled_name(ti.name()); + const string_view demangled_name = ti.name(); std::string name_copy(demangled_name.size(), '\0'); // normalize_msvc_abi_name removes class, struct, union etc that MSVC has in // front of types