mirror of
https://github.com/fmtlib/fmt.git
synced 2025-12-06 16:57:03 +08:00
parent
8db24c0ea9
commit
b77a751625
@ -41,10 +41,11 @@
|
|||||||
#include "base.h"
|
#include "base.h"
|
||||||
|
|
||||||
#ifndef FMT_MODULE
|
#ifndef FMT_MODULE
|
||||||
|
# include <stdlib.h> // malloc, free
|
||||||
|
|
||||||
# include <cmath> // std::signbit
|
# include <cmath> // std::signbit
|
||||||
# include <cstddef> // std::byte
|
# include <cstddef> // std::byte
|
||||||
# include <cstdint> // uint32_t
|
# include <cstdint> // uint32_t
|
||||||
# include <cstdlib> // std::malloc, std::free
|
|
||||||
# include <cstring> // std::memcpy
|
# include <cstring> // std::memcpy
|
||||||
# include <limits> // std::numeric_limits
|
# include <limits> // std::numeric_limits
|
||||||
# include <new> // std::bad_alloc
|
# include <new> // std::bad_alloc
|
||||||
@ -744,12 +745,12 @@ template <typename T> struct allocator : private std::decay<void> {
|
|||||||
|
|
||||||
auto allocate(size_t n) -> T* {
|
auto allocate(size_t n) -> T* {
|
||||||
FMT_ASSERT(n <= max_value<size_t>() / sizeof(T), "");
|
FMT_ASSERT(n <= max_value<size_t>() / sizeof(T), "");
|
||||||
T* p = static_cast<T*>(std::malloc(n * sizeof(T)));
|
T* p = static_cast<T*>(malloc(n * sizeof(T)));
|
||||||
if (!p) FMT_THROW(std::bad_alloc());
|
if (!p) FMT_THROW(std::bad_alloc());
|
||||||
return p;
|
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 {
|
constexpr friend auto operator==(allocator, allocator) noexcept -> bool {
|
||||||
return true; // All instances of this allocator are equivalent.
|
return true; // All instances of this allocator are equivalent.
|
||||||
|
|||||||
@ -198,7 +198,7 @@ auto write_demangled_name(OutputIt out, const std::type_info& ti) -> OutputIt {
|
|||||||
int status = 0;
|
int status = 0;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
std::unique_ptr<char, void (*)(void*)> demangled_name_ptr(
|
std::unique_ptr<char, void (*)(void*)> 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;
|
string_view demangled_name_view;
|
||||||
if (demangled_name_ptr) {
|
if (demangled_name_ptr) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user