[FFmpeg-devel] [PATCH] Get done with if (p) before av_free and av_freep
Clément Bœsch
ubitux
Fri Feb 4 07:40:53 CET 2011
Hi,
Here is two patches to get done with this. As requested, the first one is
for if before av_freep calls (just two and one comment, I wasn't able to
find more), and the second is for the av_free I missed.
I don't think there are more, or at least not in a simple form.
Regards,
--
Cl?ment B.
-------------- next part --------------
>From 2aaa5e6b862b0afa7df10274482e8bc32f5b5f99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
Date: Thu, 3 Feb 2011 11:30:17 +0100
Subject: [PATCH 1/2] Remove a few if (p) av_freep(&p) forms
---
libavcodec/libxvidff.c | 3 +--
libavutil/tree.h | 2 +-
libswscale/swscale-test.c | 3 +--
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c
index 771fc2b..9008b84 100644
--- a/libavcodec/libxvidff.c
+++ b/libavcodec/libxvidff.c
@@ -527,8 +527,7 @@ static av_cold int xvid_encode_close(AVCodecContext *avctx) {
xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
- if( avctx->extradata != NULL )
- av_freep(&avctx->extradata);
+ av_freep(&avctx->extradata);
if( x->twopassbuffer != NULL ) {
av_free(x->twopassbuffer);
av_free(x->old_twopassbuffer);
diff --git a/libavutil/tree.h b/libavutil/tree.h
index bf09fd0..8c7de2f 100644
--- a/libavutil/tree.h
+++ b/libavutil/tree.h
@@ -67,7 +67,7 @@ void *av_tree_find(const struct AVTreeNode *root, void *key, int (*cmp)(void *ke
* return av_tree_insert(rootp, key, cmp, next);
* }
* void *tree_remove(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b, AVTreeNode **next)){
- * if(*next) av_freep(next);
+ * av_freep(next);
* return av_tree_insert(rootp, key, cmp, next);
* }
* @endcode
diff --git a/libswscale/swscale-test.c b/libswscale/swscale-test.c
index ae5f8b7..bd24f3e 100644
--- a/libswscale/swscale-test.c
+++ b/libswscale/swscale-test.c
@@ -104,8 +104,7 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
int p;
for (p = 0; p < 4; p++)
- if (src[p])
- av_freep(&src[p]);
+ av_freep(&src[p]);
av_image_fill_linesizes(srcStride, srcFormat, srcW);
for (p = 0; p < 4; p++) {
--
1.7.4
-------------- next part --------------
>From 210602beca3d47913ad33c63f2504e2013a3df2f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
Date: Thu, 3 Feb 2011 11:31:41 +0100
Subject: [PATCH 2/2] Remove forgotten if (p) av_free(p) forms
---
libavfilter/defaults.c | 2 +-
libavformat/avidec.c | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
index 98339b6..9f245c3 100644
--- a/libavfilter/defaults.c
+++ b/libavfilter/defaults.c
@@ -126,7 +126,7 @@ AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int per
return ref;
fail:
- if (ref && ref->audio)
+ if (ref)
av_free(ref->audio);
av_free(ref);
av_free(samples);
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index d8d4726..27a9d1f 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -1354,8 +1354,7 @@ static int avi_read_close(AVFormatContext *s)
}
}
- if (avi->dv_demux)
- av_free(avi->dv_demux);
+ av_free(avi->dv_demux);
return 0;
}
--
1.7.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110204/0ab1f51f/attachment.pgp>
More information about the ffmpeg-devel
mailing list