Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb: use auto_obstack in parsers
@ 2026-10-26 15:31 Simon Marchi
  2026-10-26 22:29 ` Keith Seitz
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2026-10-26 15:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: use auto_obstack in parsers
  2026-10-26 15:31 [PATCH] gdb: use auto_obstack in parsers Simon Marchi
@ 2026-10-26 22:29 ` Keith Seitz
  2026-10-27  4:14   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Keith Seitz @ 2026-10-26 22:29 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

Hi,

Thank you for your parser cleanups.

On 10/26/26 8:31 AM, Simon Marchi wrote:
> Replace some manual obstack init/free with auto_obstack.
> 

This looks almost obvious, so I think it's good to go in.

Reviewed-By: Keith Seitz <keiths@redhat.com>

Keith


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: use auto_obstack in parsers
  2026-10-26 22:29 ` Keith Seitz
@ 2026-10-27  4:14   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2026-10-27  4:14 UTC (permalink / raw)
  To: Keith Seitz, Simon Marchi, gdb-patches

On 10/26/26 6:29 PM, Keith Seitz wrote:
> Hi,
> 
> Thank you for your parser cleanups.
> 
> On 10/26/26 8:31 AM, Simon Marchi wrote:
>> Replace some manual obstack init/free with auto_obstack.
>>
> 
> This looks almost obvious, so I think it's good to go in.
> 
> Reviewed-By: Keith Seitz <keiths@redhat.com>

I wasn't completely sure, I rarely touch auto_obstack.  Thanks for
checking!  I just pushed it.

Simon

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-27  4:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26 15:31 [PATCH] gdb: use auto_obstack in parsers Simon Marchi
2026-10-26 22:29 ` Keith Seitz
2026-10-27  4:14   ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox