[FFmpeg-cvslog] avformat/utils: optimize ff_packet_list_free()
James Almer
git at videolan.org
Wed Apr 4 06:57:18 EEST 2018
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Mon Mar 26 15:02:36 2018 -0300| [58ce4fdeaebce5d9837ebc77e1453e7cf3a5bb1d] | committer: James Almer
avformat/utils: optimize ff_packet_list_free()
Don't constantly overwrite the list's head pointer.
Signed-off-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=58ce4fdeaebce5d9837ebc77e1453e7cf3a5bb1d
---
libavformat/utils.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index be9a44f168..3e482a3bbc 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1416,12 +1416,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
void ff_packet_list_free(AVPacketList **pkt_buf, AVPacketList **pkt_buf_end)
{
- while (*pkt_buf) {
- AVPacketList *pktl = *pkt_buf;
- *pkt_buf = pktl->next;
+ AVPacketList *tmp = *pkt_buf;
+
+ while (tmp) {
+ AVPacketList *pktl = tmp;
+ tmp = pktl->next;
av_packet_unref(&pktl->pkt);
av_freep(&pktl);
}
+ *pkt_buf = NULL;
*pkt_buf_end = NULL;
}
More information about the ffmpeg-cvslog
mailing list