[FFmpeg-devel] [PATCH 2/5] avformat/utils: optimize ff_packet_list_free()

James Almer jamrial at gmail.com
Mon Mar 26 21:02:36 EEST 2018


Don't contantly overwrite the list's head pointer.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/utils.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index cb1ea5b386..9faffa03a3 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;
 }
 
-- 
2.16.2



More information about the ffmpeg-devel mailing list