[libc++] NFC: Synchronize libc++abi and libc++ new definitions
authorLouis Dionne <ldionne@apple.com>
Wed, 11 Nov 2020 21:33:38 +0000 (16:33 -0500)
committerLouis Dionne <ldionne@apple.com>
Wed, 11 Nov 2020 21:35:25 +0000 (16:35 -0500)
Some changes were made to the libc++abi new/delete definitions, but
they were not copied back to the libc++ definition. It sucks that we
have this duplication, but for now at least let's keep them in sync.

libcxx/src/new.cpp

index 901e785..ec60ca6 100644 (file)
@@ -130,7 +130,8 @@ _LIBCPP_WEAK
 void
 operator delete(void* ptr) _NOEXCEPT
 {
-    ::free(ptr);
+    if (ptr)
+        ::free(ptr);
 }
 
 _LIBCPP_WEAK
@@ -251,10 +252,11 @@ _LIBCPP_WEAK
 void
 operator delete(void* ptr, std::align_val_t) _NOEXCEPT
 {
+    if (ptr)
 #if defined(_LIBCPP_MSVCRT_LIKE)
-    ::_aligned_free(ptr);
+        ::_aligned_free(ptr);
 #else
-    ::free(ptr);
+        ::free(ptr);
 #endif
 }