From 052ac2761e842b10a02a9c157e23c739aaf76790 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 13 Jun 2007 12:01:30 +0000 Subject: [PATCH] --- .../platform_specific_code/juce_mac_CoreAudio.cpp | 10 +++------- .../win32/platform_specific_code/juce_win32_ASIO.cpp | 6 ++---- .../platform_specific_code/juce_win32_DirectSound.cpp | 6 ++---- .../win32/platform_specific_code/juce_win32_Fonts.cpp | 11 +++-------- .../gui/graphics/contexts/juce_EdgeTable.cpp | 3 +-- src/juce_core/basics/juce_SystemStats.cpp | 6 ++++++ 6 files changed, 17 insertions(+), 25 deletions(-) diff --git a/build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp b/build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp index 9adff9162e..5abdfa5b15 100644 --- a/build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp +++ b/build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp @@ -121,17 +121,13 @@ public: stop (false); - if (audioBuffer != 0) - juce_free (audioBuffer); - - if (inputDevice != 0) - delete inputDevice; + juce_free (audioBuffer); + delete inputDevice; } void setTempBufferSize (const int numChannels, const int numSamples) { - if (audioBuffer != 0) - juce_free (audioBuffer); + juce_free (audioBuffer); audioBuffer = (float*) juce_calloc (32 + numChannels * numSamples * sizeof (float)); diff --git a/build/win32/platform_specific_code/juce_win32_ASIO.cpp b/build/win32/platform_specific_code/juce_win32_ASIO.cpp index aa3e7701fe..db718bdcf4 100644 --- a/build/win32/platform_specific_code/juce_win32_ASIO.cpp +++ b/build/win32/platform_specific_code/juce_win32_ASIO.cpp @@ -166,8 +166,7 @@ public: log (T("ASIO - exiting")); removeCurrentDriver(); - if (tempBuffer != 0) - juce_free (tempBuffer); + juce_free (tempBuffer); if (isUsingThread) { @@ -487,8 +486,7 @@ public: jassert (! isThreadRunning()); - if (tempBuffer != 0) - juce_free (tempBuffer); + juce_free (tempBuffer); tempBuffer = (float*) juce_calloc (totalBuffers * currentBlockSizeSamples * sizeof (float) + 128); diff --git a/build/win32/platform_specific_code/juce_win32_DirectSound.cpp b/build/win32/platform_specific_code/juce_win32_DirectSound.cpp index 43cb9d82ae..077b12249f 100644 --- a/build/win32/platform_specific_code/juce_win32_DirectSound.cpp +++ b/build/win32/platform_specific_code/juce_win32_DirectSound.cpp @@ -1225,16 +1225,14 @@ private: int i; for (i = 0; i < numInputBuffers; ++i) - if (inputBuffers[i] != 0) - juce_free (inputBuffers[i]); + juce_free (inputBuffers[i]); delete[] inputBuffers; inputBuffers = 0; numInputBuffers = 0; for (i = 0; i < numOutputBuffers; ++i) - if (outputBuffers[i] != 0) - juce_free (outputBuffers[i]); + juce_free (outputBuffers[i]); delete[] outputBuffers; outputBuffers = 0; diff --git a/build/win32/platform_specific_code/juce_win32_Fonts.cpp b/build/win32/platform_specific_code/juce_win32_Fonts.cpp index 6461ebcb3c..ccc0e97b6d 100644 --- a/build/win32/platform_specific_code/juce_win32_Fonts.cpp +++ b/build/win32/platform_specific_code/juce_win32_Fonts.cpp @@ -250,9 +250,7 @@ public: { DeleteDC (dc); DeleteObject (fontH); - - if (kps) - juce_free (kps); + juce_free (kps); } } @@ -284,11 +282,8 @@ public: DeleteDC (dc); DeleteObject (fontH); - if (kps != 0) - { - juce_free (kps); - kps = 0; - } + juce_free (kps); + kps = 0; } fontH = 0; diff --git a/src/juce_appframework/gui/graphics/contexts/juce_EdgeTable.cpp b/src/juce_appframework/gui/graphics/contexts/juce_EdgeTable.cpp index 6acf6a4326..b5488f8a64 100644 --- a/src/juce_appframework/gui/graphics/contexts/juce_EdgeTable.cpp +++ b/src/juce_appframework/gui/graphics/contexts/juce_EdgeTable.cpp @@ -61,8 +61,7 @@ EdgeTable::EdgeTable (const EdgeTable& other) throw() const EdgeTable& EdgeTable::operator= (const EdgeTable& other) throw() { - if (table != 0) - juce_free (table); + juce_free (table); top = other.top; height = other.height; diff --git a/src/juce_core/basics/juce_SystemStats.cpp b/src/juce_core/basics/juce_SystemStats.cpp index 82460c1280..620ccfdaa5 100644 --- a/src/juce_core/basics/juce_SystemStats.cpp +++ b/src/juce_core/basics/juce_SystemStats.cpp @@ -66,6 +66,12 @@ void JUCE_API initialiseJuce_NonGUI() jassert (atomicDecrementAndReturn (n) == 1); jassert (swapByteOrder ((uint32) 0x11223344) == 0x44332211); + + // quick test to make sure the run-time lib doesn't crash on freeing a null-pointer. + SystemStats* nullPointer = 0; + juce_free (nullPointer); + delete[] nullPointer; + delete nullPointer; #endif // Now the real initialisation..