From 2a72d58766d5582ec32b52e419a7023db77a224e Mon Sep 17 00:00:00 2001 From: Giulio Eulisse Date: Mon, 13 Mar 2017 11:50:17 +0100 Subject: [PATCH] Remove unneeded if when deleting NULL / 0 / nullptr C++ standard dictates that NULL / 0 / nullptr is a valid argument for delete which then simply has no effect: "The value of the first argument supplied to a deallocation function may be a null pointer value; if so, and if the deallocation function is one supplied in the standard library, the call has no effect." I therefore think in these particular case it's safe to remove the ifs. --- fairmq/nanomsg/FairMQPollerNN.cxx | 5 +---- fairmq/shmem/FairMQPollerSHM.cxx | 5 +---- fairmq/zeromq/FairMQPollerZMQ.cxx | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/fairmq/nanomsg/FairMQPollerNN.cxx b/fairmq/nanomsg/FairMQPollerNN.cxx index 1a2cd252..30383b93 100644 --- a/fairmq/nanomsg/FairMQPollerNN.cxx +++ b/fairmq/nanomsg/FairMQPollerNN.cxx @@ -231,8 +231,5 @@ bool FairMQPollerNN::CheckOutput(const string channelKey, const int index) FairMQPollerNN::~FairMQPollerNN() { - if (items != NULL) - { - delete[] items; - } + delete[] items; } diff --git a/fairmq/shmem/FairMQPollerSHM.cxx b/fairmq/shmem/FairMQPollerSHM.cxx index 6d4eedf3..1a216077 100644 --- a/fairmq/shmem/FairMQPollerSHM.cxx +++ b/fairmq/shmem/FairMQPollerSHM.cxx @@ -234,8 +234,5 @@ bool FairMQPollerSHM::CheckOutput(const string channelKey, const int index) FairMQPollerSHM::~FairMQPollerSHM() { - if (items != NULL) - { - delete[] items; - } + delete[] items; } diff --git a/fairmq/zeromq/FairMQPollerZMQ.cxx b/fairmq/zeromq/FairMQPollerZMQ.cxx index ce63723c..4a50fdfc 100644 --- a/fairmq/zeromq/FairMQPollerZMQ.cxx +++ b/fairmq/zeromq/FairMQPollerZMQ.cxx @@ -234,8 +234,5 @@ bool FairMQPollerZMQ::CheckOutput(const string channelKey, const int index) FairMQPollerZMQ::~FairMQPollerZMQ() { - if (items != NULL) - { - delete[] items; - } + delete[] items; }