[libcxx-commits] [libcxx] [libc++] Refactor memory allocation in basic_string (PR #128423)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 15 09:25:52 PDT 2025
================
@@ -2250,6 +2230,63 @@ private:
return __is_long() ? __get_long_pointer() : __get_short_pointer();
}
+ // Internal buffer management
+ // --------------------------
+ //
+ // These functions are only responsible for managing the buffer itself, not the value inside the buffer. As such,
+ // none of these facilities ensure that there is a null terminator at `data()[size()]`.
+
+ // Allocate a buffer of __capacity size with __alloc and return it
+ _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 __alloc_result
----------------
ldionne wrote:
Should we return a `__long` from here instead? This might also remove the need to touch `__allocate_at_least`?
And then should `struct __rep` have a constructor from `__long` and from `__short` directly?
https://github.com/llvm/llvm-project/pull/128423
More information about the libcxx-commits
mailing list