[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 01:29:57 PDT 2018


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

Quote C89: "If ptr is a null pointer, no action occurs."


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.166632.patch
Type: text/x-patch
Size: 512 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180923/fa2753ba/attachment.bin>


More information about the cfe-commits mailing list