diff options
author | Fangrui Song <maskray@google.com> | 2018-09-25 02:50:57 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2018-09-25 02:50:57 +0000 |
commit | 6da5366ea9f92c1318a8b360062668c8e25a08e8 (patch) | |
tree | 8180773786cc563b83b9736acd5f68fd9316c3c4 /libcxx/src | |
parent | 14fefe7f8e5b62f6e3b55cb6573505c4f179b461 (diff) | |
download | bcm5719-llvm-6da5366ea9f92c1318a8b360062668c8e25a08e8.tar.gz bcm5719-llvm-6da5366ea9f92c1318a8b360062668c8e25a08e8.zip |
Remove redundant null pointer check in operator delete
C89 4.10.3.2 The free function
C99 7.20.3.2 The free function
C11 7.22.3.3 The free function
If ptr is a null pointer, no action shall occur.
_aligned_free on MSDN:
If memblock is a NULL pointer, this function simply performs no actions.
Reviewers: EricWF, mclow.lists
Subscribers: christof, ldionne, cfe-commits, libcxx-commits
Differential Revision: https://reviews.llvm.org/D52401
llvm-svn: 342936
Diffstat (limited to 'libcxx/src')
-rw-r--r-- | libcxx/src/new.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp index 8013d89ae3c..35f481db08a 100644 --- a/libcxx/src/new.cpp +++ b/libcxx/src/new.cpp @@ -135,8 +135,7 @@ _LIBCPP_WEAK void operator delete(void* ptr) _NOEXCEPT { - if (ptr) - ::free(ptr); + ::free(ptr); } _LIBCPP_WEAK @@ -257,11 +256,10 @@ _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 } |