gdb: use auto_obstack in parsers
Checks
Commit Message
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(-)
base-commit: 5d74f2038840c5e60e4b8b63fb8e64b98b26686b
Comments
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
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
@@ -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')
@@ -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;
@@ -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;