[PATCH] D53120: Implement sized deallocation for std::allocator and friends.

Richard Smith - zygoloid via Phabricator reviews at reviews.llvm.org
Thu Oct 11 16:19:20 PDT 2018


rsmith added inline comments.


================
Comment at: include/new:293-295
+    __do_call(__ptr);
+#else
+    return __do_call(__ptr, __size);
----------------
Any reason why one of these is `return`ed but the other is not?


================
Comment at: include/new:303-305
+    __do_call(__ptr, __align);
+#else
+    return __do_call(__ptr, __size, __align);
----------------
Likewise


================
Comment at: include/valarray:3732-3738
+void valarray<_Tp>::__clear(size_t __size)
 {
-    if (__begin_ != nullptr)
-    {
-        while (__end_ != __begin_)
-            (--__end_)->~value_type();
-        _VSTD::__libcpp_deallocate(__begin_, __alignof(value_type));
-        __begin_ = __end_ = nullptr;
-    }
+  if (__begin_ != nullptr)
+  {
+    while (__end_ != __begin_)
+      (--__end_)->~value_type();
+    _VSTD::__libcpp_deallocate(__begin_, __size * sizeof(value_type), __alignof(value_type));
----------------
I think `__size` would be clearer as `__capacity` here.


https://reviews.llvm.org/D53120





More information about the libcxx-commits mailing list