diff options
author | Vitor Sessak <vitor1001@gmail.com> | 2008-02-10 18:03:18 +0000 |
---|---|---|
committer | Vitor Sessak <vitor1001@gmail.com> | 2008-02-10 18:03:18 +0000 |
commit | 88cfb804184c9c2d47ddf88f5508a615fdb86ea3 (patch) | |
tree | 8ec364f2f19d1333459b81f4a6fe775c77883217 /libavfilter/formats.c | |
parent | 391354656c045dd396c398261250acdda8fea37d (diff) | |
download | ffmpeg-88cfb804184c9c2d47ddf88f5508a615fdb86ea3.tar.gz |
avfilter_formats_unref() should remove the given reference, not the last
reference.
Commited in SoC by Bobby Bingham
Originally committed as revision 11892 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavfilter/formats.c')
-rw-r--r-- | libavfilter/formats.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 49a74c2cf0..5846b9b275 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -109,8 +109,23 @@ void avfilter_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) f->refs[f->refcount-1] = ref; } +static int find_ref_index(AVFilterFormats *f, AVFilterFormats **ref) +{ + int i; + for(i = 0; i < (*ref)->refcount; i ++) + if((*ref)->refs[i] == ref) + return i; + return -1; +} + void avfilter_formats_unref(AVFilterFormats **ref) { + int idx; + + if((idx = find_ref_index(*ref, ref)) >= 0) + memmove((*ref)->refs + idx, (*ref)->refs + idx+1, + sizeof(AVFilterFormats**) * ((*ref)->refcount-idx-1)); + if(!--(*ref)->refcount) { av_free((*ref)->formats); av_free((*ref)->refs); |