[PATCH] D52401: Remove redundant null pointer check in operator delete

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 23 00:45:41 PDT 2018


MaskRay updated this revision to Diff 166629.
MaskRay edited the summary of this revision.
MaskRay added a comment.

Also remove the check for _aligned_free


Repository:
  rCXX libc++

https://reviews.llvm.org/D52401

Files:
  src/new.cpp


Index: src/new.cpp
===================================================================
--- src/new.cpp
+++ src/new.cpp
@@ -135,8 +135,7 @@
 void
 operator delete(void* ptr) _NOEXCEPT
 {
-    if (ptr)
-        ::free(ptr);
+    ::free(ptr);
 }
 
 _LIBCPP_WEAK
@@ -257,11 +256,10 @@
 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
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52401.166629.patch
Type: text/x-patch
Size: 512 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180923/fe970221/attachment.bin>


More information about the cfe-commits mailing list