Skip to content

Commit

Permalink
[libc++abi] Remove redundant null pointer check in operator delete
Browse files Browse the repository at this point in the history
Similar to D52401. Normally operator delete is defined in libc++abi
(LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS is off by default).

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.

free on MSDN:

    If memblock is NULL, the pointer is ignored and free immediately returns.

Reviewed By: #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D93339
  • Loading branch information
MaskRay committed Dec 16, 2020
1 parent e728024 commit ef74f0f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions libcxxabi/src/stdlib_new_delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ _LIBCXXABI_WEAK
void
operator delete(void* ptr) _NOEXCEPT
{
if (ptr)
::free(ptr);
::free(ptr);
}

_LIBCXXABI_WEAK
Expand Down

0 comments on commit ef74f0f

Please sign in to comment.