[libcxx-commits] [libcxx] [libc++] Refactor memory allocation in basic_string (PR #128423)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 16 01:59:34 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
----------------
philnik777 wrote:

I think updating `__rep` is a good idea, but I'd rather do it in a follow-up.

https://github.com/llvm/llvm-project/pull/128423


More information about the libcxx-commits mailing list