player: avoid leaking memory
This commit is contained in:
@@ -55,6 +55,25 @@ static const int host_bigendian = 0;
|
||||
struct {signed int x:24;} se_struct_24;
|
||||
#define SignExtend24(val) (se_struct_24.x = val)
|
||||
|
||||
void alac_free(alac_file *alac) {
|
||||
if (alac->predicterror_buffer_a)
|
||||
free(alac->predicterror_buffer_a);
|
||||
if (alac->predicterror_buffer_b)
|
||||
free(alac->predicterror_buffer_b);
|
||||
|
||||
if (alac->outputsamples_buffer_a)
|
||||
free(alac->outputsamples_buffer_a);
|
||||
if (alac->outputsamples_buffer_b)
|
||||
free(alac->outputsamples_buffer_b);
|
||||
|
||||
if (alac->uncompressed_bytes_buffer_a)
|
||||
free(alac->uncompressed_bytes_buffer_a);
|
||||
if (alac->uncompressed_bytes_buffer_b)
|
||||
free(alac->uncompressed_bytes_buffer_b);
|
||||
|
||||
free(alac);
|
||||
}
|
||||
|
||||
void alac_allocate_buffers(alac_file *alac)
|
||||
{
|
||||
alac->predicterror_buffer_a = malloc(alac->setinfo_max_samples_per_frame * 4);
|
||||
@@ -1108,6 +1127,8 @@ alac_file *alac_create(int samplesize, int numchannels)
|
||||
{
|
||||
alac_file *newfile = malloc(sizeof(alac_file));
|
||||
|
||||
memset(newfile, 0, sizeof(alac_file));
|
||||
|
||||
newfile->samplesize = samplesize;
|
||||
newfile->numchannels = numchannels;
|
||||
newfile->bytespersample = (samplesize / 8) * numchannels;
|
||||
|
||||
Reference in New Issue
Block a user