From e8d519dad79017b5157f148b7fd199e2877300ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 5 Jan 2018 16:09:25 +0100 Subject: [PATCH] Core/MemoryHelper: Make PlacementDestroy a no-op on null pointers --- include/Nazara/Core/MemoryHelper.inl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Core/MemoryHelper.inl b/include/Nazara/Core/MemoryHelper.inl index c2233bac1..dfab05f15 100644 --- a/include/Nazara/Core/MemoryHelper.inl +++ b/include/Nazara/Core/MemoryHelper.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -70,11 +70,14 @@ namespace Nz * \brief Calls the object destructor explicitly * * \param ptr Pointer to a previously constructed pointer on raw memory + * + * \remark This does not deallocate memory, and is a no-op on a null pointer */ template void PlacementDestroy(T* ptr) { - ptr->~T(); + if (ptr) + ptr->~T(); } /*!