Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH] gdb: use auto_obstack in parsers
Date: Mon, 26 Oct 2026 11:31:36 -0400	[thread overview]
Message-ID: <20261026153137.2007217-1-simon.marchi@efficios.com> (raw)

Replace some manual obstack init/free with auto_obstack.

Change-Id: Id703a8dfabac7f544f54a5b936e59e3eb34185d8
---
 gdb/c-exp-parser.c  | 9 ++-------
 gdb/d-exp-parser.c  | 9 ++-------
 gdb/go-exp-parser.c | 9 ++-------
 3 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/gdb/c-exp-parser.c b/gdb/c-exp-parser.c
index 64bf455e7220..0e6b35760dc3 100644
--- a/gdb/c-exp-parser.c
+++ b/gdb/c-exp-parser.c
@@ -350,8 +350,7 @@ parse_number (struct parser_state *par_state, const char *buf, int len,
 }
 
 /* Temporary obstack used for holding strings.  */
-static struct obstack tempbuf;
-static int tempbuf_init;
+static auto_obstack tempbuf;
 
 /* Parse a string or character literal from TOKPTR.  The string or
    character may be wide or unicode.  *OUTPTR is set to just after the
@@ -377,11 +376,7 @@ parse_string_or_char (const char *tokptr, const char **outptr,
      (as well as strings in other languages) with embedded null
      bytes */
 
-  if (!tempbuf_init)
-    tempbuf_init = 1;
-  else
-    obstack_free (&tempbuf, NULL);
-  obstack_init (&tempbuf);
+  tempbuf.clear ();
 
   /* Record the string type.  */
   if (*tokptr == 'L')
diff --git a/gdb/d-exp-parser.c b/gdb/d-exp-parser.c
index e6b5f3af8498..0fd01b490032 100644
--- a/gdb/d-exp-parser.c
+++ b/gdb/d-exp-parser.c
@@ -271,8 +271,7 @@ parse_number (struct parser_state *ps, const char *p,
 }
 
 /* Temporary obstack used for holding strings.  */
-static struct obstack tempbuf;
-static int tempbuf_init;
+static auto_obstack tempbuf;
 
 /* Parse a string or character literal from TOKPTR.  The string or
    character may be wide or unicode.  *OUTPTR is set to just after the
@@ -296,11 +295,7 @@ parse_string_or_char (const char *tokptr, const char **outptr,
      (as well as strings in other languages) with embedded null
      bytes */
 
-  if (!tempbuf_init)
-    tempbuf_init = 1;
-  else
-    obstack_free (&tempbuf, NULL);
-  obstack_init (&tempbuf);
+  tempbuf.clear ();
 
   /* Skip the quote.  */
   quote = *tokptr;
diff --git a/gdb/go-exp-parser.c b/gdb/go-exp-parser.c
index 96418dfae4fc..59afbf94bcec 100644
--- a/gdb/go-exp-parser.c
+++ b/gdb/go-exp-parser.c
@@ -230,8 +230,7 @@ parse_number (struct parser_state *par_state,
 }
 
 /* Temporary obstack used for holding strings.  */
-static struct obstack tempbuf;
-static int tempbuf_init;
+static auto_obstack tempbuf;
 
 /* Parse a string or character literal from TOKPTR.  The string or
    character may be wide or unicode.  *OUTPTR is set to just after the
@@ -255,11 +254,7 @@ parse_string_or_char (const char *tokptr, const char **outptr,
      (as well as strings in other languages) with embedded null
      bytes */
 
-  if (!tempbuf_init)
-    tempbuf_init = 1;
-  else
-    obstack_free (&tempbuf, NULL);
-  obstack_init (&tempbuf);
+  tempbuf.clear ();
 
   /* Skip the quote.  */
   quote = *tokptr;

base-commit: 5d74f2038840c5e60e4b8b63fb8e64b98b26686b
-- 
2.56.0


             reply	other threads:[~2026-10-26 15:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 15:31 Simon Marchi [this message]
2026-10-26 22:29 ` Keith Seitz
2026-10-27  4:14   ` Simon Marchi

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=20261026153137.2007217-1-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.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