Skip to content

Commit 8a07a8e

Browse files
committed
Undo my changes in __allocate_long_buffer
I had misunderstood the call `__long(__buffer, __capacity)` at the end of the function. The second parameter to that constructor is actually the string _size_, not its capacity! So it's correct that it should be passing the original `__capacity` parameter from its caller, and not the version increased for alignment.
1 parent adfb6a7 commit 8a07a8e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

libcxx/include/string

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,15 +2329,14 @@ private:
23292329
__allocate_long_buffer(_Allocator& __alloc, size_type __capacity) {
23302330
_LIBCPP_ASSERT_INTERNAL(!__fits_in_sso(__capacity),
23312331
"Trying to allocate long buffer for a capacity what would fit into the small buffer");
2332-
size_type __aligned_capacity = __align_allocation_size(__capacity);
2333-
auto __buffer = std::__allocate_at_least(__alloc, __aligned_capacity);
2332+
auto __buffer = std::__allocate_at_least(__alloc, __align_allocation_size(__capacity));
23342333

23352334
if (__libcpp_is_constant_evaluated()) {
23362335
for (size_type __i = 0; __i != __buffer.count; ++__i)
23372336
std::__construct_at(std::addressof(__buffer.ptr[__i]));
23382337
}
23392338

2340-
return __long(__buffer, __aligned_capacity);
2339+
return __long(__buffer, __capacity);
23412340
}
23422341

23432342
// Replace the current buffer with __new_rep. Deallocate the old long buffer if it exists.

0 commit comments

Comments
 (0)