From e876e45030738ae5e40f97182dd44dbfdd9555ae Mon Sep 17 00:00:00 2001 From: uau Date: Sat, 10 Feb 2007 18:12:03 +0000 Subject: [PATCH] Fix memory leaks. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22197 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libaf/af_channels.c | 8 ++++---- libaf/af_format.c | 5 +++-- libaf/af_hrtf.c | 3 ++- libaf/af_lavcresample.c | 8 ++++++-- libaf/af_resample.c | 3 ++- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/libaf/af_channels.c b/libaf/af_channels.c index 63214ec56a..8fcdb99c85 100644 --- a/libaf/af_channels.c +++ b/libaf/af_channels.c @@ -234,10 +234,10 @@ static int control(struct af_instance_s* af, int cmd, void* arg) // Deallocate memory static void uninit(struct af_instance_s* af) { - if(af->setup) - free(af->setup); - if(af->data) - free(af->data); + free(af->setup); + if (af->data) + free(af->data->audio); + free(af->data); } // Filter data through filter diff --git a/libaf/af_format.c b/libaf/af_format.c index f13b7a124a..7c660d3fe3 100644 --- a/libaf/af_format.c +++ b/libaf/af_format.c @@ -163,8 +163,9 @@ static int control(struct af_instance_s* af, int cmd, void* arg) // Deallocate memory static void uninit(struct af_instance_s* af) { - if(af->data) - free(af->data); + if (af->data) + free(af->data->audio); + free(af->data); af->setup = 0; } diff --git a/libaf/af_hrtf.c b/libaf/af_hrtf.c index ff4e53aba8..e89922ab2b 100644 --- a/libaf/af_hrtf.c +++ b/libaf/af_hrtf.c @@ -362,7 +362,8 @@ static void uninit(struct af_instance_s *af) free(af->setup); } if(af->data) - free(af->data); + free(af->data->audio); + free(af->data); } /* Filter data through filter diff --git a/libaf/af_lavcresample.c b/libaf/af_lavcresample.c index 84e709f739..1f7f69c69b 100644 --- a/libaf/af_lavcresample.c +++ b/libaf/af_lavcresample.c @@ -79,10 +79,14 @@ static int control(struct af_instance_s* af, int cmd, void* arg) static void uninit(struct af_instance_s* af) { if(af->data) - free(af->data); + free(af->data->audio); + free(af->data); if(af->setup){ af_resample_t *s = af->setup; if(s->avrctx) av_resample_close(s->avrctx); + int i; + for (i=0; i < AF_NCH; i++) + free(s->in[i]); free(s); } } @@ -109,7 +113,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) if(s->in_alloc < in_len + s->index){ s->in_alloc= in_len + s->index; for(i=0; iin[i]= realloc(s->in[i], s->in_alloc*sizeof(int16_t)); //FIXME free this maybe ;) + s->in[i]= realloc(s->in[i], s->in_alloc*sizeof(int16_t)); } } diff --git a/libaf/af_resample.c b/libaf/af_resample.c index fbc7901421..47f07125ab 100644 --- a/libaf/af_resample.c +++ b/libaf/af_resample.c @@ -298,7 +298,8 @@ static int control(struct af_instance_s* af, int cmd, void* arg) static void uninit(struct af_instance_s* af) { if(af->data) - free(af->data); + free(af->data->audio); + free(af->data); } // Filter data through filter