From patchwork Wed Aug 11 19:00:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Witten X-Patchwork-Id: 29428 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:8e8b:0:0:0:0:0 with SMTP id q133csp45036iod; Wed, 11 Aug 2021 12:01:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywj2RVu3GizOrCIvsVF1ENkSa6S7pzRP/Pjwil49zmWghQ8cyJYDztGpRrCPCZGw93Nsdg X-Received: by 2002:a17:906:2495:: with SMTP id e21mr9895ejb.244.1628708473002; Wed, 11 Aug 2021 12:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628708472; cv=none; d=google.com; s=arc-20160816; b=t18CYJgUVRuokBAI3Rru5yiX3MLbDhEYSE70wHDab//HVkSzwuMpsWLlHTzkT6yiyq 5bu29rb/4XkMYcvEn0lSscH77nVEhnhzalxDo0aNlAA971sXPaBtUQIjeHgF7orSMY1o hMxvpseqcQcXzQ54LGsTY12HZ5zcL3LIRtHE60OPQN8KGfPYQrxS1WoR3gvjwBFo2f2F bs2qZtB+LNtczWNF+mZYOtLfD7gTdXxY82F+O/sZFcS9Ph+D3E6JFt5dM5IrC5RYyNVa W1t3VWpDwNPUixlKXKxoKAvncDtUb4vdj+zAC2rnS8yCK2i+1DJsDm5gFROE+GWBKVuS BbwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:to :from:date:dkim-signature:delivered-to; bh=blvQjF7FxB2s5XQMLsq1rj3ey4r2PVcDdakPCDlaR18=; b=RFumFWYN+t+BHcMlUQprzNV63ro+WirZVM7hai9OCdNrjJIcQeAL+i7TStO0CepWqo 8SUuF7J+3lusG8vh8HtX3k4LA7pPjn7t5XYivg5/pk8vr21lAFpxb7xlBH/+vA+2xeJX Lt/DxFzX3eLSm2EgUa5z1FOloaBzBE/MnC2NQIMCEhx2/p3RohgLRxZEfU013Q67Qtnc eczQsDFNkLo6fqJwjbsIe/atvBiZF7890EZu38eEYD8BE9BY7u7BWQ6QBnqR/YWisGi5 U4fCbeF7So3LKxTc+ugOIi4EWg+OmEOyTGCnanDq1rX1HQHY2svkhRdBcZjbJLBYQwap wNVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=fSokK4lD; 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 r7si10939891ejz.374.2021.08.11.12.01.12; Wed, 11 Aug 2021 12:01:12 -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=20161025 header.b=fSokK4lD; 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 4463968A4D1; Wed, 11 Aug 2021 22:00:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4033668A4A8 for ; Wed, 11 Aug 2021 22:00:38 +0300 (EEST) Received: by mail-lj1-f178.google.com with SMTP id h2so6272228lji.6 for ; Wed, 11 Aug 2021 12:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:date:from:to:message-id:in-reply-to:references; bh=4fJF7D2yUTILkbGNIC4WLXmwAzAcU3VK7e44L4BMTG4=; b=fSokK4lD6SVq9cKBSXLDWzQ3ukVlsS5ZT50lp1z1v0Z61/gxTfoDAeH6kDKNdMILNO 5V9VF9c7IJ8AQxfPHzCBlaeMnefR2r4WxlOO1H2UQqsZSKqsajguym1rrgk1iYR/Jw8U Gn+xj28/AhWUYLzvAXzaQBtyS1bB/rnr+AoAQsSNBFbjdfMuaI4CLp2p5gn1NdD7wh2s QfWEICewNA0vsUz8DsW1g11ZcUjqvErq5qaandf60LjUXaxliY+4TlemR3aN36h+cjpv UewOFM5OeJ1zzQL/vgeMMHKuG0Y4X+AtZu0Pu+B3MbUxzzrAWe2ZhMYbYlSLLs7a6xk7 llAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:from:to:message-id:in-reply-to :references; bh=4fJF7D2yUTILkbGNIC4WLXmwAzAcU3VK7e44L4BMTG4=; b=UEvOA3wHU6vO65Ac5n5zLobo1SrZKEqguFvwESHOJQeWvbLb0Urubi4WeBXysQEU2l FyKjPzqww5JriYakiGKXLsVuldp/REiWzyl7ILlFzYvZfdifZD4vk7vChI/cz7OBRpdI NMQsUvDbEEusRVnasdJZyyM6BWBYlHfgUuWv6cUS4jAuYMH4r6jg9wpjln/jgR/DSLNv 7FiMeX/j9kgkqyaAEAxeLUApSSYrvcqORUoD3ZghdNgqnj55OCO4EfF9zbayaOLuf9NJ vi0QKk5EElP55hVMN5sYxnE7ieYRCO04DKC0hK8PhaM//HJlguBIDBb43x+DSsvIvxYx mW2w== X-Gm-Message-State: AOAM530LC8w2Hr0WBU68jDaFbl2UoTnzjzElWi5sqjNlGwcMIWl7dxG3 OxZEaan9t5ST14QLuTr5q3pDNllZBZuJ4X3W2S2IOQ== X-Received: by 2002:a2e:a7cd:: with SMTP id x13mr117330ljp.448.1628708437432; Wed, 11 Aug 2021 12:00:37 -0700 (PDT) Received: from gmail.com (tor-exit0-readme.dfri.se. [171.25.193.20]) by smtp.gmail.com with ESMTPSA id z8sm26696ljn.11.2021.08.11.12.00.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Aug 2021 12:00:37 -0700 (PDT) Date: Wed, 11 Aug 2021 19:00:04 -0000 From: Michael Witten To: ffmpeg-devel@ffmpeg.org Message-ID: In-Reply-To: References: Subject: [FFmpeg-devel] [PATCH 2.2/3] libavformat/protocols.c: avio_enum_protocols(): Convert recursion to iteration 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Ap5RWT2cgV1R In C, it's generally not good to write a recursive algorithm, because it is not possible to rely on the compiler to elide a tail call; therefore, this commit converts a tail call into an iterative loop by means of an explicit 'goto' statement. --- libavformat/protocols.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/protocols.c b/libavformat/protocols.c index 1c5e3b2bdb..b0aae66dab 100644 --- a/libavformat/protocols.c +++ b/libavformat/protocols.c @@ -95,6 +95,7 @@ const char *avio_enum_protocols(void **const opaque, const int output) { const URLProtocol *const *p; +iterate: p = *opaque; p = p ? p + 1 : url_protocols; *opaque = (void *)p; @@ -104,7 +105,7 @@ const char *avio_enum_protocols(void **const opaque, const int output) } if ((output && (*p)->url_write) || (!output && (*p)->url_read)) return (*p)->name; - return avio_enum_protocols(opaque, output); + goto iterate; } const AVClass *avio_protocol_get_class(const char *name)