Skip to content

Commit 7cd6790

Browse files
committedOct 1, 2018
Remove redundant null pointer check in operator delete
Summary: 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, khng300, hotpxl Reviewed By: mclow.lists, khng300, hotpxl Subscribers: lichray, llvm-commits, hotpxl, khng300, christof, ldionne, cfe-commits, libcxx-commits Differential Revision: https://reviews.llvm.org/D52401 llvm-svn: 343503
1 parent 23b62aa commit 7cd6790

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed
 

‎libcxx/src/new.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ _LIBCPP_WEAK
135135
void
136136
operator delete(void* ptr) _NOEXCEPT
137137
{
138-
if (ptr)
139-
::free(ptr);
138+
::free(ptr);
140139
}
141140

142141
_LIBCPP_WEAK
@@ -257,11 +256,10 @@ _LIBCPP_WEAK
257256
void
258257
operator delete(void* ptr, std::align_val_t) _NOEXCEPT
259258
{
260-
if (ptr)
261259
#if defined(_LIBCPP_MSVCRT_LIKE)
262-
::_aligned_free(ptr);
260+
::_aligned_free(ptr);
263261
#else
264-
::free(ptr);
262+
::free(ptr);
265263
#endif
266264
}
267265

0 commit comments

Comments
 (0)
Please sign in to comment.