[libcxx-commits] [libcxx] d4a1e03 - [libc++] NFC: Synchronize libc++abi and libc++ new definitions

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 11 13:35:32 PST 2020


Author: Louis Dionne
Date: 2020-11-11T16:35:25-05:00
New Revision: d4a1e03c5fb588a8e3f41110de437b38d4e57bbf

URL: https://github.com/llvm/llvm-project/commit/d4a1e03c5fb588a8e3f41110de437b38d4e57bbf
DIFF: https://github.com/llvm/llvm-project/commit/d4a1e03c5fb588a8e3f41110de437b38d4e57bbf.diff

LOG: [libc++] NFC: Synchronize libc++abi and libc++ new definitions

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.

Added: 
    

Modified: 
    libcxx/src/new.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp
index 901e78565857..ec60ca64815f 100644
--- a/libcxx/src/new.cpp
+++ b/libcxx/src/new.cpp
@@ -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
 }
 


        


More information about the libcxx-commits mailing list