[libcxx-commits] [libcxx] [libc++] Refactor some code in monotonic_buffer_resource (PR #117271)
Peng Xie via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Nov 23 14:39:58 PST 2024
================
@@ -429,23 +429,18 @@ static void* align_down(size_t align, size_t size, void*& ptr, size_t& space) {
return ptr;
}
-void* monotonic_buffer_resource::__initial_descriptor::__try_allocate_from_chunk(size_t bytes, size_t align) {
- if (!__cur_)
- return nullptr;
- void* new_ptr = static_cast<void*>(__cur_);
- size_t new_capacity = (__cur_ - __start_);
- void* aligned_ptr = align_down(align, bytes, new_ptr, new_capacity);
- if (aligned_ptr != nullptr)
- __cur_ = static_cast<char*>(new_ptr);
- return aligned_ptr;
-}
-
-void* monotonic_buffer_resource::__chunk_footer::__try_allocate_from_chunk(size_t bytes, size_t align) {
- void* new_ptr = static_cast<void*>(__cur_);
- size_t new_capacity = (__cur_ - __start_);
+template <typename Chunk, bool is_initial = false>
----------------
love1angel wrote:
> I think the explicitly specified template parameter should appear first.
>
> The usages below should be modified correspondingly.
done
https://github.com/llvm/llvm-project/pull/117271
More information about the libcxx-commits
mailing list