1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-04 13:33:34 +00:00

Fix Source memory leak;

This commit is contained in:
bjorn 2017-01-06 19:15:03 -08:00
parent 33a34b60b1
commit 1e2294a345
2 changed files with 3 additions and 0 deletions

View file

@ -20,6 +20,7 @@ typedef struct {
int bufferSize; int bufferSize;
void* buffer; void* buffer;
void* decoder; void* decoder;
void* data;
} SourceData; } SourceData;
typedef struct { typedef struct {

View file

@ -22,12 +22,14 @@ SourceData* lovrSourceDataFromFile(void* data, int size) {
sourceData->decoder = decoder; sourceData->decoder = decoder;
sourceData->bufferSize = sourceData->channels * 4096 * sizeof(short); sourceData->bufferSize = sourceData->channels * 4096 * sizeof(short);
sourceData->buffer = malloc(sourceData->bufferSize); sourceData->buffer = malloc(sourceData->bufferSize);
sourceData->data = data;
return sourceData; return sourceData;
} }
void lovrSourceDataDestroy(SourceData* sourceData) { void lovrSourceDataDestroy(SourceData* sourceData) {
stb_vorbis_close(sourceData->decoder); stb_vorbis_close(sourceData->decoder);
free(sourceData->data);
free(sourceData->buffer); free(sourceData->buffer);
free(sourceData); free(sourceData);
} }