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:
parent
33a34b60b1
commit
1e2294a345
|
@ -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 {
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue