Skip to content

Commit

Permalink
Remove unnecessary nullptr checks. (#807)
Browse files Browse the repository at this point in the history
Fixes #671.
  • Loading branch information
MarkCallow authored Nov 29, 2023
1 parent 26d7d3f commit 072a4eb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
20 changes: 7 additions & 13 deletions tests/loadtests/glloadtests/GLLoadTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ GLLoadTests::GLLoadTests(const sampleInvocation samples[],

GLLoadTests::~GLLoadTests()
{
if (pCurSample != nullptr) {
delete pCurSample;
}
delete pCurSample;
}

bool
Expand All @@ -61,9 +59,7 @@ GLLoadTests::initialize(Args& args)
void
GLLoadTests::finalize()
{
if (pCurSample != nullptr) {
delete pCurSample;
}
delete pCurSample;
GLAppSDL::finalize();
}

Expand Down Expand Up @@ -181,13 +177,11 @@ GLLoadTests::invokeSample(Direction dir)
{
const sampleInvocation* sampleInv = &siSamples[sampleIndex];

if (pCurSample != nullptr) {
delete pCurSample;
// Certain events can be triggered during new sample initialization
// while pCurSample is not valid, e.g. FOCUS_LOST. Protect against
// problems from this by indicating there is no current sample.
pCurSample = nullptr;
}
delete pCurSample;
// Certain events can be triggered during new sample initialization
// while pCurSample is not valid, e.g. FOCUS_LOST. Protect against
// problems from this by indicating there is no current sample.
pCurSample = nullptr;

uint32_t unsupportedTypeExceptions = 0;
std::string fileTitle;
Expand Down
3 changes: 1 addition & 2 deletions tests/loadtests/vkloadtests/InstancedSampleBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ InstancedSampleBase::cleanup()
quad.freeResources(vkctx.device);
uniformDataVS.freeResources(vkctx.device);

if (uboVS.instance != nullptr)
delete[] uboVS.instance;
delete[] uboVS.instance;
}

void
Expand Down
8 changes: 2 additions & 6 deletions tests/loadtests/vkloadtests/VulkanLoadTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ VulkanLoadTests::VulkanLoadTests(const sampleInvocation samples[],

VulkanLoadTests::~VulkanLoadTests()
{
if (pCurSample != nullptr) {
delete pCurSample;
}
delete pCurSample;
}

bool
Expand All @@ -73,9 +71,7 @@ VulkanLoadTests::initialize(Args& args)
void
VulkanLoadTests::finalize()
{
if (pCurSample != nullptr) {
delete pCurSample;
}
delete pCurSample;
VulkanAppSDL::finalize();
}

Expand Down
4 changes: 2 additions & 2 deletions tests/texturetests/texturetests.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* -*- tab-width: 4; -*- */
/* -*- tab-width: 4; -*- */
/* vi: set sw=2 ts=4 expandtab: */

/**
Expand Down Expand Up @@ -288,7 +288,7 @@ class ktxTextureTestBase : public ::testing::Test {
}

~ktxTextureTestBase() {
if (ktxMemFile != NULL) delete ktxMemFile;
delete ktxMemFile;
}

KTX_error_code
Expand Down
6 changes: 3 additions & 3 deletions tools/ktx2check/ktx2check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,8 @@ class ktxValidator : public ktxApp {
}

~validationContext() {
if (pDfd4Format != nullptr) delete pDfd4Format;
if (pActualDfd != nullptr) delete pActualDfd;
delete pDfd4Format;
delete pActualDfd;
}

size_t kvDataEndOffset() {
Expand Down Expand Up @@ -793,7 +793,7 @@ class ktxValidator : public ktxApp {
}

void init(istream* is) {
if (pDfd4Format != nullptr) delete pDfd4Format;
delete pDfd4Format;
inp = is;
dataSizeFromLevelIndex = 0;
}
Expand Down

0 comments on commit 072a4eb

Please sign in to comment.