From patchwork Mon May 1 11:44:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 41431 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp3133418pzb; Mon, 1 May 2023 04:45:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6PQ7BcY+c7opNiUozjH9bEalJa2fkpR6/9Q8wq2ctc+tjYZPkoD+hDBIySrrw3ex45A3kw X-Received: by 2002:a17:907:97c9:b0:953:43a1:1988 with SMTP id js9-20020a17090797c900b0095343a11988mr10444566ejc.46.1682941548776; Mon, 01 May 2023 04:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682941548; cv=none; d=google.com; s=arc-20160816; b=lKw5gZthzXsWb3xnjn1lmJzlZ0zfEGwTWa5IiSDO7psvbBHw8eBrqbZl3DWNU5w5Mi GKl7rSyrQx7T8Gvb3Sd/oHWrerTjDg1l37aFoXTiyBwWswrao/AamCnmpCBg2l8oE5aM AdkYEdcuEo/25VubF3xQRQw3QomfyyBLEiMuk/QrlW5kTTqlu05kSJRFn2qw+rPwwHjF iOix2NJ6HGQ4B/DjjKFEuwplIpf5qngRI2yxbMKpnHrv26IjpTvS0XlknV1cX19kDTxs b+T/jn7wqXhKT5qS9vw9oWwY1Zy9P4++6vFgDwTGpQzyB70XO/zMvG08PPLDw/Q3Kz7j N2SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=f7ker/tIZ0EgVCxBhfm3fuEuZGFlIh4EGmI19Ta7uTY=; b=aVVCmpcW5h5EI5/2HUWWQN3kJBC3aG5RJURJJtMB5WYrFLRt6N/fUrVCJPG/Rl+Mbw 37fu0T0tcfXa7STno/sIwejqvBUhJCRyEkSBzR3WuPrI7iYL0yD15WKK44320HyWwkPN C5i11VygO0iZKFUVU0l8HLJD9mOzdZSs+DKInVYnncNZ6C0dqpet4OqlMu63xqB3kw3t lqQ3Jw+AFYxRaaMFCAdKxdkBcZpjptJ0OqOse9UVWneu9Aaglhzd0aLKNXjb33bFY/PL AD87PtpOKCaiun5C2zFWRr/A0dyvevnyI1MqS+uNr4MJrgHAV7fiKsa0bp0z4j8ChqVd fcKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=QjgG3GRz; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c11-20020a170906528b00b0095388276b97si19807006ejm.420.2023.05.01.04.45.48; Mon, 01 May 2023 04:45:48 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=QjgG3GRz; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6075968C0A7; Mon, 1 May 2023 14:45:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B16268BF55 for ; Mon, 1 May 2023 14:45:30 +0300 (EEST) Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-50bcb00a4c2so300852a12.1 for ; Mon, 01 May 2023 04:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682941529; x=1685533529; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HAKiW7LeftOMyO2NsippwASjzYykGzfItlfghOxejVQ=; b=QjgG3GRzlecMSMkHj7DhnAHXHF7+8DVivY/4yMcaC5LDqY1eAxUQrG7XDssERKGIUO AYqSomo/aufcVtrocx3hJU7GP4OutGfSTTxBxE6CwcgNqljsEuFP+bvW6rrYeQ6JjEfm 1ll5eDNSt3wYDi9IfTCTfehxUZf7r29tke8EH04aNjVn94C6SdaSo7CMMSYKdBw+1aLF Z1Sc3vw0+5X8PHsyYP1Vio7+Qy1d6yq5xmVm4I5v8q60ScgWHXjV1ayM38ChBhZaEkPP pC3GDATu4Gm6E6QeSQzRY2kjngUC0ud4DdV6gkoqhK2o8jAhMmP16NI3oMYCK9jgBoFA 1b3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682941529; x=1685533529; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HAKiW7LeftOMyO2NsippwASjzYykGzfItlfghOxejVQ=; b=Kip4Qhjw17kRJXYftNQEwOnlEbsH2dRf8pJRkPXMkng80J1j9CjzNhp0sJSSa5mFy0 iSEoJInoMHIbvrYB/n4Wz+rmfaY/vsZc3F3tHr1nRNLnIQEHwI2cb13LyLZAB1znH8ce PydpiZj8O9kDwTFZM+iziZbZoIObdihuabpWXj5gCGeTv8RDe5rXvpQ01YVuTH8lKg7b /DaPmlhy1FrwxzbpoWifjfYyaY6IFRprlGEVLfQWBY9NDU0NIpduUY38vl4zQTJNwOta CUmpvGgVZV1PeGibF3xxsCi1b044IrB6YCD81lBg6xCzbKqY255YDCtgkxcX3ZJSvj9h oT+g== X-Gm-Message-State: AC+VfDw4DapAYyfWgbFp2m+UnSVJlPGVyVFmi9dVOhLM1euifMJ0bTzs MEfg17095cOs2nYB1Pdtv6JN+0t859s0XQ== X-Received: by 2002:aa7:c985:0:b0:50b:c42b:b737 with SMTP id c5-20020aa7c985000000b0050bc42bb737mr2551590edt.37.1682941529557; Mon, 01 May 2023 04:45:29 -0700 (PDT) Received: from MBP-von-Marvin.citadel.scalie.me (84-112-104-25.cable.dynamic.surfer.at. [84.112.104.25]) by smtp.gmail.com with ESMTPSA id f15-20020a056402150f00b00506adf55ae2sm12024942edw.6.2023.05.01.04.45.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 04:45:29 -0700 (PDT) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Mon, 1 May 2023 13:44:55 +0200 Message-Id: <20230501114456.13898-2-epirat07@gmail.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230501114456.13898-1-epirat07@gmail.com> References: <20230501114456.13898-1-epirat07@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avformat/tee: use av_dict_pop X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Marvin Scholz Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Ti9mzOKff3b2 This is a well-defined way to "steal" the value of the dict entry. --- libavformat/tee.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavformat/tee.c b/libavformat/tee.c index cb555f52fd..70f3f2eb29 100644 --- a/libavformat/tee.c +++ b/libavformat/tee.c @@ -157,6 +157,7 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) { int i, ret; AVDictionary *options = NULL, *bsf_options = NULL; + char *entry_val = NULL; AVDictionaryEntry *entry; char *filename; char *format = NULL, *select = NULL, *on_fail = NULL; @@ -171,15 +172,15 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) return ret; #define CONSUME_OPTION(option, field, action) do { \ - if ((entry = av_dict_get(options, option, NULL, 0))) { \ - field = entry->value; \ + if ((!av_dict_pop(&options, option, NULL, &entry_val, 0))) { \ + field = entry_val; \ { action } \ - av_dict_set(&options, option, NULL, 0); \ + av_freep(&entry_val); \ } \ } while (0) #define STEAL_OPTION(option, field) \ CONSUME_OPTION(option, field, \ - entry->value = NULL; /* prevent it from being freed */) + entry_val = NULL; /* prevent it from being freed */) #define PROCESS_OPTION(option, field, function, on_error) \ CONSUME_OPTION(option, field, if ((ret = function) < 0) { { on_error } goto end; })