mem_free is safe on null pointers

This commit is contained in:
HMH 2017-07-28 15:42:32 +02:00
parent 6655b35bdd
commit 04e2946efc
2 changed files with 4 additions and 10 deletions

View file

@ -108,9 +108,7 @@ void *mem_alloc_debug(const char *filename, int line, unsigned size, unsigned al
Frees a block allocated through <mem_alloc>.
Remarks:
- In the debug version of the library the function will assert if
a non-valid block is passed, like a null pointer or a block that
isn't allocated.
- Is safe on null pointers.
See Also:
<mem_alloc>

View file

@ -357,11 +357,8 @@ int CSound::Shutdown()
SDL_CloseAudio();
SDL_QuitSubSystem(SDL_INIT_AUDIO);
lock_destroy(m_SoundLock);
if(m_pMixBuffer)
{
mem_free(m_pMixBuffer);
m_pMixBuffer = 0;
}
mem_free(m_pMixBuffer);
m_pMixBuffer = 0;
return 0;
}
@ -690,8 +687,7 @@ void CSound::UnloadSample(int SampleID)
return;
Stop(SampleID);
if (m_aSamples[SampleID].m_pData != 0x0)
mem_free(m_aSamples[SampleID].m_pData);
mem_free(m_aSamples[SampleID].m_pData);
m_aSamples[SampleID].m_pData = 0x0;
}