Fix memory leak not freeing stb_decode ptr

This commit is contained in:
Doyle Thai 2016-09-01 02:53:17 +10:00
parent 4c38abc672
commit da07ce3f75

View File

@ -266,6 +266,7 @@ INTERNAL i32 initRendererForPlayback(MemoryArena *arena,
return result; return result;
} }
#include <stdlib.h>
const i32 audio_playVorbis(MemoryArena *arena, AudioManager *audioManager, const i32 audio_playVorbis(MemoryArena *arena, AudioManager *audioManager,
AudioRenderer *audioRenderer, AudioVorbis *vorbis, AudioRenderer *audioRenderer, AudioVorbis *vorbis,
i32 numPlays) i32 numPlays)
@ -281,6 +282,10 @@ const i32 audio_playVorbis(MemoryArena *arena, AudioManager *audioManager,
soundSamples, numSamples * vorbis->info.channels * sizeof(i16), soundSamples, numSamples * vorbis->info.channels * sizeof(i16),
vorbis->info.sample_rate); vorbis->info.sample_rate);
// NOTE(doyle): stb_vorbis specific implementation requires free()
// TODO(doyle): Object pool this and use our malloc to avoid dependency in Audio.c
free(soundSamples);
audioRenderer->audio = vorbis; audioRenderer->audio = vorbis;
audioRenderer->isStreaming = FALSE; audioRenderer->isStreaming = FALSE;
audioRenderer->state = audiostate_playing; audioRenderer->state = audiostate_playing;