From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id D19683858CDB; Sun, 2 Apr 2023 19:27:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D19683858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x532.google.com with SMTP id t10so109118695edd.12; Sun, 02 Apr 2023 12:27:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680463678; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=BpLgLWngpkvMs+CMpxJnmc3BxDGanzvVw38NVRoOIYg=; b=HUvUm51hjjO1Ggfcmo91XLb5fZsHT92RaOUKFgprOaBsjrtSmr9/a+qsd38atUjldF FnTriBVSlwj2ep8hXjOnEZvO7qr05ifeExrvBs2WjWGtauLT7lN/Gj/AD+MnZlYkCzKu 3FVUFExuiJ3OLTXkT6t2iz3LDWShgAOktz0YgM29gBR9Z4UOf7KPMl/zGPrAjQPxEXxX c2SOaVJsqqsST9mxoWGxt7NOT/dTJGy+u3898Unomjv6HpjYN2pxJeb3BPHtj853Ofkp l4G4wzSmW0U6x3b0IJLepEo22h0tLdeGcwLUk26OW/NnbiXKt0YOWmEo5jGKxmrH2olz sYhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680463678; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BpLgLWngpkvMs+CMpxJnmc3BxDGanzvVw38NVRoOIYg=; b=7o/K0ImbUYQ8JG0X/AI9sR3H+ZjEXt4pGUpfhmGvmSeLXkSwI7XhCvN6Hruamod4aI cFjp2G4UH9Br548yN9h2ULEt5Oi3C8PLDeomBhvsvrrG8W+JBm0UxRgFlNHJ6KnbV1WY BTeDkh1O5HNG5i9z74RWQiJ8MbBABiYNnjciKKGg6oFGVQemSAT3dDNbVV0Gx+Fp34PX q7oRPweUTrX05y4myk9RGdSDQ31hErhsP+k0y6+OYY9k3NQO/1s4zSmR+HO1GexGpBrp RtMr4FhqTFMAkOmTsp3IiEm3Lak/plLQk0147VKJsZ8yS9Gzlj9xGq1coPcDI1vKMTkb lXRw== X-Gm-Message-State: AAQBX9cfye+iqgWsYzX1by+X7k+3mmY0NuTdPzLp5acdWde15MAVkF94 Cvc3gP64O5iET+kdT0buYOU= X-Google-Smtp-Source: AKy350ZhLftaJwZz9A0i3Zq3AO/Pghj6K3pUIxL6UiJWSsaEmz2oBEg6zAOW3mkXMTEEIebzMYHDEg== X-Received: by 2002:a17:906:d117:b0:93b:a0c8:1cec with SMTP id b23-20020a170906d11700b0093ba0c81cecmr35146253ejz.32.1680463678287; Sun, 02 Apr 2023 12:27:58 -0700 (PDT) Received: from nbbrfq ([2001:871:227:1e16:8ec:e883:b72a:18fd]) by smtp.gmail.com with ESMTPSA id r3-20020a170906350300b00930876176e2sm3509420eja.29.2023.04.02.12.27.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 12:27:57 -0700 (PDT) Date: Sun, 2 Apr 2023 21:27:53 +0200 From: Bernhard Reutner-Fischer To: fortran@gcc.gnu.org Cc: rep.dot.nop@gmail.com, Harald Anlauf , gcc-patches@gcc.gnu.org, Bernhard Reutner-Fischer , nathan@acm.org, dmalcolm@redhat.com Subject: Re: [PATCH 2/2] Fortran: Fix memory leak in gfc_add_include_path [PR68800] Message-ID: <20230402212753.05eee653@nbbrfq> In-Reply-To: <20211107023821.34234999@nbbrfq> References: <20211105211718.2261686-1-rep.dot.nop@gmail.com> <20211105211718.2261686-3-rep.dot.nop@gmail.com> <20211107023821.34234999@nbbrfq> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: ping? libcpp maintainers, is the helper in incpath.* ok? fortraners, Do you prefer a rogue, local forward declaration, or is the introduction of that trivial wrapper ok? I don't think pulling in cpp.h from f95-lang.cc is desirable, but i can do that if you all think that's preferred. cover-letter: https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583522.html gcc/incpath.* bits (i guess that'd be for the libcpp maintainers): https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583520.html fortran bits: https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583521.html thanks, On Sun, 7 Nov 2021 02:38:21 +0100 Bernhard Reutner-Fischer wrote: > On Sat, 6 Nov 2021 20:22:53 +0100 > Harald Anlauf wrote: > > > Hi Bernhard, > > > > I cannot comment on the gcc/ parts, but > > > > > > diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c > > > index e86386c8b17..04fe8fe460b 100644 > > > --- a/gcc/fortran/cpp.c > > > +++ b/gcc/fortran/cpp.c > > > @@ -728,12 +728,20 @@ gfc_cpp_done (void) > > > cpp_clear_file_cache (cpp_in); > > > } > > > > why do you introduce a wrapper for something outside of fortran > > that is used only once, > > > > > -/* PATH must be malloc-ed and NULL-terminated. */ > > > +/* Free all cpp include dirs. */ > > > +void > > > +gfc_cpp_free_cpp_dirs (void) > > > +{ > > > + free_cpp_dirs (); > > > +} > > > > diff --git a/gcc/fortran/cpp.h b/gcc/fortran/cpp.h > > > index 44644a2a333..963b9a9c89e 100644 > > > --- a/gcc/fortran/cpp.h > > > +++ b/gcc/fortran/cpp.h > > > @@ -46,6 +46,7 @@ void gfc_cpp_post_options (bool); > > > bool gfc_cpp_preprocess (const char *source_file); > > > > > > void gfc_cpp_done (void); > > > +void gfc_cpp_free_cpp_dirs (void); > > > > > > void gfc_cpp_add_include_path (char *path, bool user_supplied); > > > void gfc_cpp_add_include_path_after (char *path, bool user_supplied); > > > diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c > > > index 58dcaf01d75..ec4c2cf01d9 100644 > > > --- a/gcc/fortran/f95-lang.c > > > +++ b/gcc/fortran/f95-lang.c > > > @@ -275,7 +275,7 @@ gfc_finish (void) > > > gfc_cpp_done (); > > > gfc_done_1 (); > > > gfc_release_include_path (); > > > - return; > > > > namely here? > > > > > + gfc_cpp_free_cpp_dirs (); > > > } > > > > Why not call free_cpp_dirs () here directly, omit all unnecessary > > stuff, and maybe only add a brief comment here? > > cpp.c includes incpath.h, f95-lang.c does not and should not. > So the cleanest thing is to keep the cpp handling in cpp.[ch] and have > the language frontend call into it's cpp bits. > > It would be rather rogue to > extern void free_cpp_dirs (void); > in f95-lang.c and directly call it in gfc_finish, i'd say? > > thanks,