From 58ce4fdeaebce5d9837ebc77e1453e7cf3a5bb1d Mon Sep 17 00:00:00 2001 From: James Almer <jamrial@gmail.com> Date: Mon, 26 Mar 2018 15:02:36 -0300 Subject: [PATCH] avformat/utils: optimize ff_packet_list_free() Don't constantly overwrite the list's head pointer. Signed-off-by: James Almer <jamrial@gmail.com> --- libavformat/utils.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index be9a44f1682..3e482a3bbc1 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; } -- GitLab