diff mbox series

[FFmpeg-devel,3/3] avformat/hls: Use av_init_pkt() directly

Message ID 20200814212029.22861-2-andreas.rheinhardt@gmail.com
State Accepted
Commit 97d802914994b29eba97dc49e35e8ed60b5b8ae3
Headers show
Series [FFmpeg-devel] avformat/hls: Fix memleak when url is empty | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Aug. 14, 2020, 9:20 p.m. UTC
and remove reset_packet(). The packet's data pointer is already zeroed,
so the only thing that reset_packet() does that av_init_pkt() doesn't is
redundant.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/hls.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

Comments

Steven Liu Aug. 17, 2020, 12:47 a.m. UTC | #1
Andreas Rheinhardt <andreas.rheinhardt@gmail.com> 于2020年8月15日周六 上午5:21写道:
>
> and remove reset_packet(). The packet's data pointer is already zeroed,
> so the only thing that reset_packet() does that av_init_pkt() doesn't is
> redundant.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/hls.c | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 8217c5ede4..3ab07f1b3f 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -293,28 +293,18 @@ static void free_rendition_list(HLSContext *c)
>      c->n_renditions = 0;
>  }
>
> -/*
> - * Used to reset a statically allocated AVPacket to a clean state,
> - * containing no data.
> - */
> -static void reset_packet(AVPacket *pkt)
> -{
> -    av_init_packet(pkt);
> -    pkt->data = NULL;
> -}
> -
>  static struct playlist *new_playlist(HLSContext *c, const char *url,
>                                       const char *base)
>  {
>      struct playlist *pls = av_mallocz(sizeof(struct playlist));
>      if (!pls)
>          return NULL;
> -    reset_packet(&pls->pkt);
>      ff_make_absolute_url(pls->url, sizeof(pls->url), base, url);
>      if (!pls->url[0]) {
>          av_free(pls);
>          return NULL;
>      }
> +    av_init_packet(&pls->pkt);
>      pls->seek_timestamp = AV_NOPTS_VALUE;
>
>      pls->is_id3_timestamped = -1;
> --
> 2.20.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".


LGTM

Thanks
Steven
diff mbox series

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 8217c5ede4..3ab07f1b3f 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -293,28 +293,18 @@  static void free_rendition_list(HLSContext *c)
     c->n_renditions = 0;
 }
 
-/*
- * Used to reset a statically allocated AVPacket to a clean state,
- * containing no data.
- */
-static void reset_packet(AVPacket *pkt)
-{
-    av_init_packet(pkt);
-    pkt->data = NULL;
-}
-
 static struct playlist *new_playlist(HLSContext *c, const char *url,
                                      const char *base)
 {
     struct playlist *pls = av_mallocz(sizeof(struct playlist));
     if (!pls)
         return NULL;
-    reset_packet(&pls->pkt);
     ff_make_absolute_url(pls->url, sizeof(pls->url), base, url);
     if (!pls->url[0]) {
         av_free(pls);
         return NULL;
     }
+    av_init_packet(&pls->pkt);
     pls->seek_timestamp = AV_NOPTS_VALUE;
 
     pls->is_id3_timestamped = -1;