[libcxx-commits] [libcxx] [libc++] Replace __libcpp_allocate with std::allocator in small_bufer.h (PR #234158)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 21 04:20:18 PDT 2026
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/234158
None
>From 56fd5d718e0b9814f3b2a03083379fd2fde7af95 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Wed, 21 Oct 2026 13:19:56 +0200
Subject: [PATCH] [libc++] Replace __libcpp_allocate with std::allocator in
small_bufer.h
---
libcxx/include/__utility/small_buffer.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/__utility/small_buffer.h b/libcxx/include/__utility/small_buffer.h
index 132a57f0fefab1..0dae0544cdecee 100644
--- a/libcxx/include/__utility/small_buffer.h
+++ b/libcxx/include/__utility/small_buffer.h
@@ -12,6 +12,7 @@
#include <__config>
#include <__cstddef/byte.h>
#include <__cstddef/size_t.h>
+#include <__memory/allocator.h>
#include <__memory/construct_at.h>
#include <__new/allocate.h>
#include <__new/launder.h>
@@ -68,7 +69,7 @@ class __small_buffer {
if constexpr (__fits_in_buffer<_Stored>) {
return std::launder(reinterpret_cast<_Stored*>(__buffer_));
} else {
- byte* __allocation = reinterpret_cast<byte*>(std::__libcpp_allocate<_Stored>(__element_count(1)));
+ byte* __allocation = reinterpret_cast<byte*>(std::allocator<_Stored>().allocate(1));
std::construct_at(reinterpret_cast<byte**>(__buffer_), __allocation);
return std::launder(reinterpret_cast<_Stored*>(__allocation));
}
@@ -77,7 +78,7 @@ class __small_buffer {
template <class _Stored>
_LIBCPP_HIDE_FROM_ABI void __dealloc() noexcept {
if constexpr (!__fits_in_buffer<_Stored>)
- std::__libcpp_deallocate<_Stored>(__get<_Stored>(), __element_count(1));
+ std::allocator<_Stored>().deallocate(__get<_Stored>(), 1);
}
template <class _Stored, class... _Args>
More information about the libcxx-commits
mailing list