From patchwork Tue Sep 13 19:46:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 37907 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp906509pzh; Tue, 13 Sep 2022 12:46:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Wo83Q0bs5qNa8pAZ+I9xTVZjsOQhx7L42Gxj1LjBPcr9101RtSaOqJx/U8pQxivTAB3LI X-Received: by 2002:a17:907:75e7:b0:77b:e654:ef23 with SMTP id jz7-20020a17090775e700b0077be654ef23mr10776284ejc.631.1663098410537; Tue, 13 Sep 2022 12:46:50 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 9-20020a170906210900b007318652a31bsi8955552ejt.577.2022.09.13.12.46.50; Tue, 13 Sep 2022 12:46:50 -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=@outlook.com header.s=selector1 header.b=Wx6lUB7c; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9C92868BAE4; Tue, 13 Sep 2022 22:46:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073070.outbound.protection.outlook.com [40.92.73.70]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 90D8168BA90 for ; Tue, 13 Sep 2022 22:46:38 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SILyr1dENYRurRvXdBvlDnqogMf/QUcNmlVFfMhPJ7PXdfF/RLHGHoHyocXgm05mRm7C54K2aHuT/Q4yjIfNkHOx0vD4mea93jEkFwOh4305qKYNWVesQqPoqS+zOx3UZgwPUhGb2eLvIILB/3uv36kkTe2qLWfrDYyRoq3AQy7ia+ae5LB1GVlnx+LfD1nnEDyJ5wx8iyXBs4T1AYZnOFP0nMMBMPOCVl2FhWMUewTyFvAhc1KtYCM0gv329Mq1jdKByN49HT2yBBm+SNd8WnJ8U71BB8uojfKNny3t8eI3/lDKMHp4VIVzJXlBM2frOqwUbJX3agvgbR9JXUvs7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6giXAvI3Kce5Bl3T9Qpte3rM1i+Dzcr7fUDGtiH7eTk=; b=SY1ZXanakjiD8ij9D6u76ugnslwS0D4EH18LrygUYTmJZbxs82GG5k/hjB8DwXpnjsNvntQOXuxyAlTXQWhZUh1XOsvbWwl/9D2kCjxUd9qVnHRInr+CBuQ5XR5uwvboYyGDkhaTm4fjy6bqcLqMiDmYZuP6hXnBj82WR99H+BlAJL4znyeFzs+07vQqy+FUdq1ANM0P5ioLCSTk76CKt8onRdYSN1IU2CcHfa59It9WfIxPQuETgO/NVSh3n9B5seOvVBAtw6IRRuCTo+QMnipRrGh4SNJoG3IyFFmBn4tb2CZSXLVVoUhgf+RGeQzOxqMLXTu9oMv8LW81H8gwAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6giXAvI3Kce5Bl3T9Qpte3rM1i+Dzcr7fUDGtiH7eTk=; b=Wx6lUB7c4jlvVTa1ZLEJumOdZJHEY9iFwNJY/lYfX4fHYuXwh+X++JMb4KZIXdIWUimJx1sJ3cxPxDeEgc+NCfh5y+qme2xTIHAa4c1zSFwIIbLEPzMnM2FYDEs1mdqYoG2pOLfRtFWDmnOMHEPKE52d9rdhRAfBfne+x6KxjZh0hkrXN1Pl0KcDGdAwTm4xCOYHjrwu0t6ju+QNjYikwReK7/8PMBVVGNSJdnqwyEJlHn3YUf2cknRvs96IwCXaeCvZWXJPwD46G9K7N9TbViPmgUd8ZrGuYj+GfgJRoNQ+JBkgLOBxMa/R89Qs4pvPXjKhhmgTYdg6MYeIYclZLA== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PAXP250MB0446.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:276::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.22; Tue, 13 Sep 2022 19:46:34 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::51a4:ed23:ea45:dfeb]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::51a4:ed23:ea45:dfeb%8]) with mapi id 15.20.5612.022; Tue, 13 Sep 2022 19:46:34 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 13 Sep 2022 21:46:28 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [5TFxFROGctiS2c9dCigwQcpIprbIgkKm64+HIDH48y0=] X-ClientProxiedBy: ZR0P278CA0115.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:20::12) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20220913194628.922446-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|PAXP250MB0446:EE_ X-MS-Office365-Filtering-Correlation-Id: 265de58c-7c6c-4f78-97da-08da95c0a9e1 X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmpEumVcsW5TnTvXPpg27e8v73j8CMZjERtIj4VMvctmUqZZkFaDpzr/t/xVMUj/o2Wcs7jSzkIQvMMP2Mj6wMVG3gKFTwJbFT14hPf1fhGjZBfKIttJagjqyjKTpBLxeEzm7fmHYpRKG+mDzDLG5yv2RlEpil+fm1anvcMMCSsffqx71J90kRMovYc9qZQoWTE5Ewn8FY9idcrSHS/Da1spdMlz+ECh937n18/GELr8lAIwLY7L4mnCCmYhqK67D1pv7+hfFRRBloefK1qg7yYcyjx+FXifu89lCNP8U9qcKQ3aa06E9I1fjNncXlTKHFIC+TbAQ4MjVCCFRhYpFgmuU0jAFxJnfTuxhOFL7BTFxHI6dmjF+VZ3LwDpZIkmKPbwlWWugmGtKEfUFEfBvWW0bUDgPV0G6988aPTpr2FIc7PvU/fjqJRGlLmuIZAXowfcChsoYuTYa7dUu2n4gh+kDqW6CnQSoRSrn8IzTJzbp+CRiBqNDxNQsD6LYoRe7dQGTWNvf6oUZmW21Ah87yg4IzUyGPJOrvTnZeBtUPx4HY/lri9VyWtYptdTcXHn8+uFyMAXwNlKzmJLJQH+Q7xBR5BfoMLkbkp/xK2i34smaHdbXfYg1jY69XyzxIc+qtN48/KQ4YMY93axWwOAy99ILXZU4QNvF8zeOAffsh8uCjyECQAOqFve3ta+ZoAb3osE9IBvgR0qL/n4xgHZFfZ+K4m2LWK+ohWkAD52qI2pgG83z3KHs7f47co84WWyCxc= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XpYdlqSspvc+KNOpF122CEehoY25z4+29OISgfvZyGLrPoElZBrsxIa9b9XbwGavZ4Z6LcTczbTL/0D80cXRGSUIuLOMZDhWdcC2lMIGf0v3d4axuePedLg+1otWvKEKreIclxH3JdGxahvgZ+462Pdz5btuoqQJyEuJDbEG+va5CHZlH9BXbZY0EUOnaKZh6K70LImj6sN97YqBE8XWAHwtZwf+8tCCfuAqkIsKUwX39Z99L5cdP6oaP2zUuyndiAjqwJlYz+y68/FuhARO4x2H2+UKhzcVnzetmDQQgHgvVgK9l11qwEb0/9vILvfHUtytIxDZrTfLU7DEM3z7m3zkoUE1oXVuopNlsFtwV4+7so7HmPwIwhAnlGkpOVPKI97Og9gKutDw0piMoElbiu+Led2IeBsx8F3+ZaccmdwDxx+j/T3d3MJl/HTzmc4wf4Gwde3wgG47sI23dl7+sLXQaJ4WyXfIp58v2ovE8w/OReQrMlS4cK6PUUaxy+oONa6guxQitqj0Rl7yzPYwDHhqTemj5aqsreIs21PoB0NF1hJ7HuyAo9QZndxoTCm4hBQPwAnko4tXVfXVZWwH45onzw1zLBscYsF020p5eojjXs2R5go1/0mcItt0YszB+BtXNE9vjbFJx+V3izeWCQ== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: axiMam1of7juZgpGfHSwElU2WnMy87M2y26Y5m5OzEPIDbdvh9e5go3rxg6cxI9uIVvwGs5cI5TII60R+F2lfM0Uvrm6uqzTHSl3+CO5UKVZ0SYrGTu/LCxc+ZyP2cbtbWvhRGSGwFRnFiqrAL7DQ3Ekid4vbdhXZ2eMfcm5rlPerP01BpOBNukxNfymFNphFLmHyOwN/RmZ9pgoQYloWrHZn8m+yUVobMqP2dLxu85wEFv08Fw5C/W00mMP12ln34hzimcg7A5NUoF2czs5sE4WZbVuWi8y6kyHguDcMsm9u8xQtyReRDKbCVeqsIFQga/oP72UBd1zNMy9LjEylkmoXnDLesKjsNWdGxdpnfckpZd+n0Tm5nuh8eMQIOF9gKVKK2sdT9657lTYsodw3KWEnh+XioWuTXpWh2d0UJxRJXCqtuw9GG2fFebe6r8EqpEWk1RkIZrNH0ItybSYS+GN9PxD74o5RZmkIMTrHLw5q5V8Cwa/pc5ow11O5v4eLvDcHhARfprZsRwXzPUcX25kef6FhclLr8T5RfzmQAdbkiVjHqfbv8wR6oyp+EA0OLjJ9nTVK5yhQhQv6y2dxMOfVK4TQKne6vQz6LauWbt7qoXkzFUxmN/t9wKzJIYlRyVryg2eDVv4FKOGUx5hzAq1J40l53rAx87HoHYEkYjT2m56uIhILRnb4hKT90c3IBDI613eRoWu5ejxO89nApEEHCu4Es8jH1u9Fn7jrfylqb7KcrXLBOHkCTK2Y4ZlOokORMfsk5PwOBLIye8L6hxNpt4fO+w2ufgK3ad+Po3MzGHm6folfN9OkJdhc5QwZggOw3hWkHTGPgde1lspmusTwIpUYFyN+Ily5jWRvuYH3GQ77nQdsOUQvH2ECpbCRt3f9OlgBnMVVua9T3poiUXuIazXK+3pl0/nRQTVEr+u16ld9KKB5kZZ06fGw5l2RGth/KtS0lZIOSJOnqBKnUb//QXs/7oTH5RJp3u4EKBuYnB0vZovUoXULV4XYJCH3/VyzJIwO9Nss+uDxuekFjpXwrJo+Kf1CQSnTIrjbs14lBdcXGLghvmREbKrggrj5hQRq17yD1EvEFFBz3fLM6JO8GSZgKVAm9IoHIw0d1Bo2goBXjSKLSDWHKUfmEhDnw6eBitegK1t46ztdyZJvr+sefy3kEF9/Rvaa4yQ/aHj47KytVkuodDq/TMG6tokjkwl5G5D8131zpEtCAzpxeyM5c/twoGnMv82V5FoeC1o46HXWHUP34pT40qWRhdswZmcvix1TNeLUr7Fj7Ez3NCReuj+u6pw6t9bbLwrdIPCnjIA0Wa7VH2bfUYAFPB8 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 265de58c-7c6c-4f78-97da-08da95c0a9e1 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2022 19:46:34.4939 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXP250MB0446 Subject: [FFmpeg-devel] [PATCH 3/3] avutil/dict: Avoid check whose result is known in advance 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: HSJ76dss4vBh We know that an AVDictionary is not empty if we have just added an entry to it, so only check for it being empty on the branch that does not do so. Signed-off-by: Andreas Rheinhardt --- libavutil/dict.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavutil/dict.c b/libavutil/dict.c index 1968063b0b..4bba041d0a 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -123,12 +123,12 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, m->elems[m->count].value = copy_value; m->count++; } else { + if (!m->count) { + av_freep(&m->elems); + av_freep(pm); + } av_freep(©_key); } - if (!m->count) { - av_freep(&m->elems); - av_freep(pm); - } return 0;