From 2780dacb480bb008922606cd007a49d18dc3dff7 Mon Sep 17 00:00:00 2001 From: peri4 Date: Thu, 13 Apr 2023 20:40:14 +0300 Subject: [PATCH] new piDeleteSafety() method --- CMakeLists.txt | 2 +- libs/main/core/pibase.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83a23a28..2fa929f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake project(PIP) set(PIP_MAJOR 3) set(PIP_MINOR 10) -set(PIP_REVISION 1) +set(PIP_REVISION 2) set(PIP_SUFFIX ) set(PIP_COMPANY SHS) set(PIP_DOMAIN org.SHS) diff --git a/libs/main/core/pibase.h b/libs/main/core/pibase.h index 451168a9..4f073d6d 100644 --- a/libs/main/core/pibase.h +++ b/libs/main/core/pibase.h @@ -974,6 +974,14 @@ inline void piDeleteAllAndClear(T & container) { container.clear(); } +template +inline bool piDeleteSafety(T *& pointer) { + if (!pointer) return false; + delete pointer; + pointer = nullptr; + return true; +} + #define piRoundf piRound #define piRoundd piRound #define piComparef piCompare