From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C997745826 for ; Sun, 25 Jun 2023 10:49:33 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BE54468C1E8; Sun, 25 Jun 2023 13:49:23 +0300 (EEST) Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AA32B68C198 for ; Sun, 25 Jun 2023 13:49:17 +0300 (EEST) Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-98e1c6a687fso43598266b.1 for ; Sun, 25 Jun 2023 03:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687690157; x=1690282157; 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=lD23HklJJXZoOVByzoyV1qm9X2zqB/ZGL8ewLomD2XB3EPIPC5RPpSXMU90kG+CtN4 QHOU5MveKCFwo1AmdmvNSIZIk4wxHnAtpSkR7iu/HbgiuEXPhSVTy/W5pLO3l7eVg9I0 C8z0iPALDVH4wL/Hc7duWLrtbgmaZFwhXDdVH9h3zMG6hgSE7K8tFCAcqT60uBlFr/nK zy/ALU3HADaJq7F4kdu8wfwBg/BkIuHgPaMYExSqwFKzsVHIiiGbjN+RausduTDlENtY KZ+Zg6DpGe719NfK1MQNMXFrciYjU/6xHsxAB32f/Ihw43jxpUpjQPNPf5f5ZGI4bPQQ 55kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687690157; x=1690282157; 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=JZ91t0qDC78QktM9kDubbwLErNYT+nYKxDozCFHz/QWM4SsNdB82ua09YL4oCWD/5c hUQWFoFSFS7Ck1uw8au9CXpZQOFiMSa0JQt/2fMeVt/qTPwjtUFPUeFeg3UHFV+rMXwG zvoTdaSf+PLWsO5JZ7Ad5NjrY85KKpTycrksi09cLTtAIKIAzl2fmdene6ASm5yMOo+4 VDVZPJTEFRjTloL2Mteil0hUqSDTwCf5Zvs/22yG6Dp1PDSHB3vK1P/8pnjOYre/b2/u Xsd9C+DvhMUBirE98HUxnMWGZ3X/Vt3hGlIXD6XBsYJMlGIpTx2w3S3s4WnLgXjVB3U6 yhpw== X-Gm-Message-State: AC+VfDyTg1ZXuDVT5eJN7ntLzQ3B4etBpfcKKBMtEl7b4fHCPxFWCTcx r8EqBrk3EjSTbiQRD8rhl0SslMOWRgHkJg== X-Google-Smtp-Source: ACHHUZ4RE/Va+S1e6UZDgo4lqMhAGMJTBtArgWKJ7hwi9W+YMlhAns7ojTmaUwb9hq86i94u+DGkBQ== X-Received: by 2002:a17:907:934e:b0:988:f1ec:7400 with SMTP id bv14-20020a170907934e00b00988f1ec7400mr12024483ejc.36.1687690156810; Sun, 25 Jun 2023 03:49:16 -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 br26-20020a170906d15a00b0096f7cf96525sm1952877ejb.146.2023.06.25.03.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jun 2023 03:49:16 -0700 (PDT) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Sun, 25 Jun 2023 12:49:06 +0200 Message-Id: <20230625104907.53071-2-epirat07@gmail.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230625104907.53071-1-epirat07@gmail.com> References: <20230501114456.13898-1-epirat07@gmail.com> <20230625104907.53071-1-epirat07@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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; }) -- 2.37.0 (Apple Git-136) _______________________________________________ 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".