[libcxx-commits] [libcxx] 8775913 - [libc++] Replace __libcpp_allocate with std::allocator in small_bufer.h (#234158)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 21 04:21:31 PDT 2026
Author: Nikolas Klauser
Date: 2026-10-21T13:21:26+02:00
New Revision: 8775913d9b4a58a4162f2c865f31a213ac96f4c0
URL: https://github.com/llvm/llvm-project/commit/8775913d9b4a58a4162f2c865f31a213ac96f4c0
DIFF: https://github.com/llvm/llvm-project/commit/8775913d9b4a58a4162f2c865f31a213ac96f4c0.diff
LOG: [libc++] Replace __libcpp_allocate with std::allocator in small_bufer.h (#234158)
We use `__libcpp_allocate` and frineds only in very specific
circumstances. Instead of providing a private API we can make
`std::allocator` the default API for the uses of `__libcpp_allocate`.
This is a step towards that goal.
Added:
Modified:
libcxx/include/__utility/small_buffer.h
Removed:
################################################################################
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