public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org
Cc: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>,
	Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
Subject: [PATCH 1/2] Add free_cpp_dirs()
Date: Fri,  5 Nov 2021 22:17:17 +0100	[thread overview]
Message-ID: <20211105211718.2261686-2-rep.dot.nop@gmail.com> (raw)
In-Reply-To: <20211105211718.2261686-1-rep.dot.nop@gmail.com>

From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>

gcc/ChangeLog:

	* incpath.c (free_cpp_dirs): New function.
	* incpath.h (free_cpp_dirs): Ditto.

---
This adds a helper to allow the fortran FE to free it's include dirs.

Bootstrapped and regtested without new regressions on x86_64-unknown-linux.
Ok for trunk?
---
 gcc/incpath.c | 13 +++++++++++++
 gcc/incpath.h |  1 +
 2 files changed, 14 insertions(+)

diff --git a/gcc/incpath.c b/gcc/incpath.c
index 52dbb806b1b..de77a56062c 100644
--- a/gcc/incpath.c
+++ b/gcc/incpath.c
@@ -513,6 +513,19 @@ get_added_cpp_dirs (incpath_kind chain)
   return heads[chain];
 }
 
+/* Free all cpp dirs.  */
+void
+free_cpp_dirs (void)
+{
+  struct cpp_dir **pcur, *cur;
+  for (pcur = &heads[INC_QUOTE]; *pcur;)
+    {
+      cur = *pcur;
+      *pcur = cur->next;
+      free_path (cur, REASON_QUIET);
+    }
+}
+
 #if !(defined TARGET_EXTRA_INCLUDES) || !(defined TARGET_EXTRA_PRE_INCLUDES)
 static void hook_void_charptr_charptr_int (const char *sysroot ATTRIBUTE_UNUSED,
 					   const char *iprefix ATTRIBUTE_UNUSED,
diff --git a/gcc/incpath.h b/gcc/incpath.h
index 2a4a314d7f9..4bf878b4e74 100644
--- a/gcc/incpath.h
+++ b/gcc/incpath.h
@@ -34,6 +34,7 @@ extern void register_include_chains (cpp_reader *, const char *,
 				     int, int, int);
 extern void add_cpp_dir_path (struct cpp_dir *, incpath_kind);
 extern struct cpp_dir *get_added_cpp_dirs (incpath_kind);
+extern void free_cpp_dirs(void);
 
 struct target_c_incpath_s {
   /* Do extra includes processing.  STDINC is false iff -nostdinc was given.  */
-- 
2.33.0


  reply	other threads:[~2021-11-05 21:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05 21:17 [PATCH 0/2] incpath, Fortran: Fix memory leak in gfc_add_include_path Bernhard Reutner-Fischer
2021-11-05 21:17 ` Bernhard Reutner-Fischer [this message]
2021-11-05 21:17 ` [PATCH 2/2] Fortran: Fix memory leak in gfc_add_include_path [PR68800] Bernhard Reutner-Fischer
2021-11-06 19:22   ` Harald Anlauf
2021-11-07  1:38     ` Bernhard Reutner-Fischer
2023-04-02 19:27       ` Bernhard Reutner-Fischer
2021-11-05 22:59 ` [PATCH 0/2] incpath, Fortran: Fix memory leak in gfc_add_include_path Bernhard Reutner-Fischer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211105211718.2261686-2-rep.dot.nop@gmail.com \
    --to=rep.dot.nop@gmail.com \
    --cc=aldot@gcc.gnu.org \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).