From patchwork Mon Sep 16 01:03:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 15084 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id C6D49449719 for ; Mon, 16 Sep 2019 04:04:02 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B29AE687FC0; Mon, 16 Sep 2019 04:04:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BCCC8687F76 for ; Mon, 16 Sep 2019 04:03:56 +0300 (EEST) Received: by mail-pf1-f195.google.com with SMTP id q5so21841101pfg.13 for ; Sun, 15 Sep 2019 18:03:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=H0e6nIfDsK7rW59rjNxxnJo8yNAIWTm281ghdZfLr9I=; b=C91yW2qdTylMKfiN3ECtjmKjnfTuNSEPzV3mYtEtloxJ3MV5mYV2VjgBGnI1aIgRqB 8fiq7hzeuEJiMnnu3/+2uFUt2GalxM1bgaekXFiSAdelTzANzJw8BJQbY0ZwF6UmLRFJ 5y34xexRBP5stZ7ZWaZXhe+fvo3WIftusfMH2DAsbXZdr/Po8gG8xJ1zn0bdHL/MB3MB Qo6Pgp/0Kbr0/zxuT/b6wW3kVB74sLgtOpRksdeD0a6knJOnK5hALeyq2tqmYq63d71v +fGU0nRaYLFkg67hzpDIipxxwpth/PjVGk+Fk332cjgAGS4eCHinJ0ASgjhRpC0uVWQ/ ViWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=H0e6nIfDsK7rW59rjNxxnJo8yNAIWTm281ghdZfLr9I=; b=uFNaFmuHT/b8CEi45QB94KNY2dBDQaocyW92XA1bYKX9eHePyEyilrFv5/NjnC1OT4 UD7QamJbf8grVgUYsBhMtLtKGBYxRG0qIbey3yBqJ5Jq3JaoRNuMOhkfoeKBF3St198m x4tjXAy+HifK6LF/ltL+JC5S9EsgaClEElLrosJfJU6EvhU0JxeOjue/MVpcnloeXkza O3XCmO4fMPY/D7GgrtFATtw7F8THGkqvsCp2ehjwg5iGXRhpFm4Nu9q2MnSMBXr1V/l9 h0YxKfwpVwqXAfKZJZniOK01Cj8R1Q65sN6yswJfKMIZYc6kxefvgK06vh1BP5SkcxxE Zr/g== X-Gm-Message-State: APjAAAU2SMlz3l5Z70e7uiMaNjXDswQS9MsOhpbiFGPf2DZVEbzqYueJ 8IBGtiZB5NJiVXV74zDFd3/RVdDW X-Google-Smtp-Source: APXvYqy7vZrKtjnpZnXqeEO600FYNo7zpWD7Ea+eMm00dLgQzbpoKqjOBXtED4GTbJVM7MLohC5cOg== X-Received: by 2002:a65:66c8:: with SMTP id c8mr27166188pgw.318.1568595834809; Sun, 15 Sep 2019 18:03:54 -0700 (PDT) Received: from vpn2.localdomain ([47.90.123.189]) by smtp.gmail.com with ESMTPSA id a17sm2797218pfi.178.2019.09.15.18.03.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Sep 2019 18:03:54 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Sep 2019 09:03:38 +0800 Message-Id: <1568595818-7943-4-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568595818-7943-1-git-send-email-lance.lmwang@gmail.com> References: <1568595818-7943-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v1 4/4] avformat/hlsenc: replace with av_freep for all av_free X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavformat/hlsenc.c | 64 ++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 21fb9d7a1d..6dc92b786e 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -590,7 +590,7 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls, if ((ret = vs->vtt_avf->io_open(vs->vtt_avf, &out, sub_path, AVIO_FLAG_WRITE, &options)) < 0) { if (hls->ignore_io_errors) ret = 0; - av_free(sub_path); + av_freep(&sub_path); goto fail; } ff_format_io_close(vs->vtt_avf, &out); @@ -598,18 +598,18 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls, av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n", sub_path, strerror(errno)); } - av_free(sub_path); + av_freep(&sub_path); } av_freep(&path); previous_segment = segment; segment = previous_segment->next; - av_free(previous_segment); + av_freep(&previous_segment); } fail: - av_free(path); - av_free(dirname); - av_free(vtt_dirname); + av_freep(&path); + av_freep(&dirname); + av_freep(&vtt_dirname); return ret; } @@ -887,7 +887,7 @@ static int sls_flags_filename_process(struct AVFormatContext *s, HLSContext *hls strlen(vs->current_segment_final_filename_fmt)) { char * new_url = av_strdup(vs->current_segment_final_filename_fmt); if (!new_url) { - av_free(en); + av_freep(&en); return AVERROR(ENOMEM); } ff_format_set_url(vs->avf, new_url); @@ -898,8 +898,8 @@ static int sls_flags_filename_process(struct AVFormatContext *s, HLSContext *hls "Invalid second level segment filename template '%s', " "you can try to remove second_level_segment_size flag\n", vs->avf->url); - av_free(filename); - av_free(en); + av_freep(&filename); + av_freep(&en); return AVERROR(EINVAL); } ff_format_set_url(vs->avf, filename); @@ -912,8 +912,8 @@ static int sls_flags_filename_process(struct AVFormatContext *s, HLSContext *hls "Invalid second level segment filename template '%s', " "you can try to remove second_level_segment_time flag\n", vs->avf->url); - av_free(filename); - av_free(en); + av_freep(&filename); + av_freep(&en); return AVERROR(EINVAL); } ff_format_set_url(vs->avf, filename); @@ -985,7 +985,7 @@ static int sls_flag_use_localtime_filename(AVFormatContext *oc, HLSContext *c, V av_log(c, AV_LOG_ERROR, "Invalid second level segment filename template '%s', " "you can try to remove second_level_segment_index flag\n", oc->url); - av_free(filename); + av_freep(&filename); return AVERROR(EINVAL); } ff_format_set_url(oc, filename); @@ -999,7 +999,7 @@ static int sls_flag_use_localtime_filename(AVFormatContext *oc, HLSContext *c, V av_log(c, AV_LOG_ERROR, "Invalid second level segment filename template '%s', " "you can try to remove second_level_segment_size flag\n", oc->url); - av_free(filename); + av_freep(&filename); return AVERROR(EINVAL); } ff_format_set_url(oc, filename); @@ -1010,7 +1010,7 @@ static int sls_flag_use_localtime_filename(AVFormatContext *oc, HLSContext *c, V av_log(c, AV_LOG_ERROR, "Invalid second level segment filename template '%s', " "you can try to remove second_level_segment_time flag\n", oc->url); - av_free(filename); + av_freep(&filename); return AVERROR(EINVAL); } ff_format_set_url(oc, filename); @@ -1098,7 +1098,7 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, if ((ret = hls_delete_old_segments(s, hls, vs)) < 0) return ret; } else - av_free(en); + av_freep(&en); } else vs->nb_entries++; @@ -1207,7 +1207,7 @@ static void hls_free_segments(HLSSegment *p) while (p) { en = p; p = p->next; - av_free(en); + av_freep(&en); } } @@ -1574,7 +1574,7 @@ static int hls_start(AVFormatContext *s, VariantStream *vs) #else vs->basename, 'd', vs->sequence) < 1) { #endif - av_free(filename); + av_freep(&filename); av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s', you can try to use -strftime 1 with it\n", vs->basename); return AVERROR(EINVAL); } @@ -1619,7 +1619,7 @@ static int hls_start(AVFormatContext *s, VariantStream *vs) #else vs->basename, 'd', vs->sequence) < 1) { #endif - av_free(filename); + av_freep(&filename); av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s' you can try to use -strftime 1 with it\n", vs->basename); return AVERROR(EINVAL); } @@ -1633,7 +1633,7 @@ static int hls_start(AVFormatContext *s, VariantStream *vs) #else vs->vtt_basename, 'd', vs->sequence) < 1) { #endif - av_free(filename); + av_freep(&filename); av_log(vtt_oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", vs->vtt_basename); return AVERROR(EINVAL); } @@ -2096,7 +2096,7 @@ static int update_variant_stream_info(AVFormatContext *s) hls->var_streams[0].streams = av_mallocz(sizeof(AVStream *) * hls->var_streams[0].nb_streams); if (!hls->var_streams[0].streams) { - av_free(hls->var_streams); + av_freep(&hls->var_streams); return AVERROR(ENOMEM); } @@ -2104,7 +2104,7 @@ static int update_variant_stream_info(AVFormatContext *s) if (hls->nb_ccstreams) { hls->var_streams[0].ccgroup = av_strdup(hls->cc_streams[0].ccgroup); if (!hls->var_streams[0].ccgroup) { - av_free(hls->var_streams); + av_freep(&hls->var_streams); return AVERROR(ENOMEM); } } @@ -2301,7 +2301,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) if (!vs->init_range_length) { range_length = avio_close_dyn_buf(oc->pb, &buffer); avio_write(vs->out, buffer, range_length); - av_free(buffer); + av_freep(&buffer); vs->init_range_length = range_length; avio_open_dyn_buf(&oc->pb); vs->packets_written = 0; @@ -2370,8 +2370,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) reflush_dynbuf(vs, &range_length); ret = hlsenc_io_close(s, &vs->out, filename); } - av_free(vs->temp_buffer); - av_free(filename); + av_freep(&vs->temp_buffer); + av_freep(&filename); } } @@ -2389,7 +2389,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) vs->end_pts = pkt->pts; vs->duration = 0; if (ret < 0) { - av_free(old_filename); + av_freep(&old_filename); return ret; } } @@ -2401,7 +2401,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) ff_format_io_close(s, &vs->out); vs->out = NULL; if ((ret = hls_window(s, 0, vs)) < 0) { - av_free(old_filename); + av_freep(&old_filename); return ret; } } @@ -2427,7 +2427,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) sls_flag_file_rename(hls, vs, old_filename); ret = hls_start(s, vs); } - av_free(old_filename); + av_freep(&old_filename); if (ret < 0) { return ret; @@ -2514,7 +2514,7 @@ static int hls_write_trailer(struct AVFormatContext *s) filename = av_asprintf("%s", oc->url); } if (!filename) { - av_free(old_filename); + av_freep(&old_filename); return AVERROR(ENOMEM); } @@ -2527,7 +2527,7 @@ static int hls_write_trailer(struct AVFormatContext *s) range_length = avio_close_dyn_buf(oc->pb, &buffer); avio_write(vs->out, buffer, range_length); - av_free(buffer); + av_freep(&buffer); vs->init_range_length = range_length; avio_open_dyn_buf(&oc->pb); vs->packets_written = 0; @@ -2569,10 +2569,10 @@ static int hls_write_trailer(struct AVFormatContext *s) if (ret < 0) av_log(s, AV_LOG_WARNING, "Failed to upload file '%s' at the end.\n", oc->url); } - av_free(vs->temp_buffer); + av_freep(&vs->temp_buffer); failed: - av_free(filename); + av_freep(&filename); av_write_trailer(oc); if (oc->url[0]) { proto = avio_find_protocol_name(oc->url); @@ -2582,7 +2582,7 @@ failed: // rename that segment from .tmp to the real one if (use_temp_file && !(hls->flags & HLS_SINGLE_FILE)) { hls_rename_temp_file(s, oc); - av_free(old_filename); + av_freep(&old_filename); old_filename = av_strdup(oc->url); if (!old_filename) {