diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 31f1057ee..62534540c 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -156,7 +156,7 @@ EIGEN_DEVICE_FUNC inline void* handmade_aligned_malloc(std::size_t size, /** \internal Frees memory allocated with handmade_aligned_malloc */ EIGEN_DEVICE_FUNC inline void handmade_aligned_free(void* ptr) { - if (ptr) { + if (ptr != nullptr) { uint8_t offset = static_cast(*(static_cast(ptr) - 1)); void* original = static_cast(static_cast(ptr) - offset); @@ -224,9 +224,11 @@ EIGEN_DEVICE_FUNC inline void* aligned_malloc(std::size_t size) { EIGEN_DEVICE_FUNC inline void aligned_free(void* ptr) { #if (EIGEN_DEFAULT_ALIGN_BYTES == 0) || EIGEN_MALLOC_ALREADY_ALIGNED - if (ptr) check_that_malloc_is_allowed(); - EIGEN_USING_STD(free) - free(ptr); + if (ptr != nullptr) { + check_that_malloc_is_allowed(); + EIGEN_USING_STD(free) + free(ptr); + } #else handmade_aligned_free(ptr); @@ -294,9 +296,11 @@ EIGEN_DEVICE_FUNC inline void conditional_aligned_free(void* ptr) { template <> EIGEN_DEVICE_FUNC inline void conditional_aligned_free(void* ptr) { - if (ptr) check_that_malloc_is_allowed(); - EIGEN_USING_STD(free) - free(ptr); + if (ptr != nullptr) { + check_that_malloc_is_allowed(); + EIGEN_USING_STD(free) + free(ptr); + } } template