[FFmpeg-cvslog] avcodec/iirfilter: Change ff_iir_filter_free_coeffs() so it clears the pointers as well
Michael Niedermayer
git at videolan.org
Tue Oct 14 18:44:28 CEST 2014
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Oct 14 18:30:52 2014 +0200| [43fb16cf74718fe6c393c5f20d0bfaea4e3e8cb4] | committer: Michael Niedermayer
avcodec/iirfilter: Change ff_iir_filter_free_coeffs() so it clears the pointers as well
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=43fb16cf74718fe6c393c5f20d0bfaea4e3e8cb4
---
libavcodec/iirfilter.c | 13 +++++++------
libavcodec/iirfilter.h | 2 +-
libavcodec/psymodel.c | 2 +-
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/libavcodec/iirfilter.c b/libavcodec/iirfilter.c
index a2d9d11..b47f91d 100644
--- a/libavcodec/iirfilter.c
+++ b/libavcodec/iirfilter.c
@@ -196,7 +196,7 @@ av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc,
return c;
init_fail:
- ff_iir_filter_free_coeffs(c);
+ ff_iir_filter_free_coeffsp(&c);
return NULL;
}
@@ -304,13 +304,14 @@ av_cold void ff_iir_filter_free_state(struct FFIIRFilterState *state)
av_free(state);
}
-av_cold void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs)
+av_cold void ff_iir_filter_free_coeffsp(struct FFIIRFilterCoeffs **coeffsp)
{
+ struct FFIIRFilterCoeffs *coeffs = *coeffsp;
if(coeffs){
- av_free(coeffs->cx);
- av_free(coeffs->cy);
+ av_freep(&coeffs->cx);
+ av_freep(&coeffs->cy);
}
- av_free(coeffs);
+ av_freep(coeffsp);
}
void ff_iir_filter_init(FFIIRFilterContext *f) {
@@ -347,7 +348,7 @@ int main(void)
for (i = 0; i < SIZE; i++)
printf("%6d %6d\n", x[i], y[i]);
- ff_iir_filter_free_coeffs(fcoeffs);
+ ff_iir_filter_free_coeffsp(&fcoeffs);
ff_iir_filter_free_state(fstate);
return 0;
}
diff --git a/libavcodec/iirfilter.h b/libavcodec/iirfilter.h
index 4ea6642..cc9a661 100644
--- a/libavcodec/iirfilter.h
+++ b/libavcodec/iirfilter.h
@@ -104,7 +104,7 @@ struct FFIIRFilterState* ff_iir_filter_init_state(int order);
*
* @param coeffs pointer allocated with ff_iir_filter_init_coeffs()
*/
-void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs);
+void ff_iir_filter_free_coeffsp(struct FFIIRFilterCoeffs **coeffs);
/**
* Free filter state.
diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c
index 22d2497..e7f3353 100644
--- a/libavcodec/psymodel.c
+++ b/libavcodec/psymodel.c
@@ -138,7 +138,7 @@ void ff_psy_preprocess(struct FFPsyPreprocessContext *ctx, float **audio, int ch
av_cold void ff_psy_preprocess_end(struct FFPsyPreprocessContext *ctx)
{
int i;
- ff_iir_filter_free_coeffs(ctx->fcoeffs);
+ ff_iir_filter_free_coeffsp(&ctx->fcoeffs);
if (ctx->fstate)
for (i = 0; i < ctx->avctx->channels; i++)
ff_iir_filter_free_state(ctx->fstate[i]);
More information about the ffmpeg-cvslog
mailing list