]> git.sesse.net Git - ffmpeg/commitdiff
avformat/utils: optimize ff_packet_list_free()
authorJames Almer <jamrial@gmail.com>
Mon, 26 Mar 2018 18:02:36 +0000 (15:02 -0300)
committerJames Almer <jamrial@gmail.com>
Wed, 4 Apr 2018 03:15:38 +0000 (00:15 -0300)
Don't constantly overwrite the list's head pointer.

Signed-off-by: James Almer <jamrial@gmail.com>
libavformat/utils.c

index be9a44f168242e0e91fd1e9d0c11ef68daa129da..3e482a3bbc18bd13ab9b676a051914bf402efc81 100644 (file)
@@ -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;
 }