Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 2/3] Remove string-related cleanup from c-exp.y
Date: Sat, 05 Jan 2019 20:41:00 -0000	[thread overview]
Message-ID: <20190105204112.26849-3-tom@tromey.com> (raw)
In-Reply-To: <20190105204112.26849-1-tom@tromey.com>

This removes a string-related cleanup from c-exp.y, by adding a new
member to c_parse_state to store the strings.

gdb/ChangeLog
2019-01-05  Tom Tromey  <tom@tromey.com>

	* c-exp.y (struct c_parse_state) <strings>: New member.
	(operator_stoken): Update.
---
 gdb/ChangeLog | 5 +++++
 gdb/c-exp.y   | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index eb6a6847cf..83b2aa3fdd 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -74,6 +74,9 @@ struct c_parse_state
      allocated during the parse.  */
   std::vector<std::unique_ptr<std::vector<struct type *>>> type_lists;
   std::vector<std::unique_ptr<struct type_stack>> type_stacks;
+
+  /* Storage for some strings allocated during the parse.  */
+  std::vector<gdb::unique_xmalloc_ptr<char>> strings;
 };
 
 /* This is set and cleared in c_parse.  */
@@ -1743,7 +1746,7 @@ operator_stoken (const char *op)
   st.ptr = buf;
 
   /* The toplevel (c_parse) will free the memory allocated here.  */
-  make_cleanup (free, buf);
+  cpstate->strings.emplace_back (buf);
   return st;
 };
 
-- 
2.17.2


  reply	other threads:[~2019-01-05 20:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-05 20:41 [PATCH 0/3] Remove cleanups " Tom Tromey
2019-01-05 20:41 ` Tom Tromey [this message]
2019-01-06  5:01   ` [PATCH 2/3] Remove string-related cleanup " Simon Marchi
2019-01-05 20:41 ` [PATCH 1/3] Use std::vector in type stacks Tom Tromey
2019-01-06  4:59   ` Simon Marchi
2019-01-06 16:40     ` Tom Tromey
2019-01-05 20:41 ` [PATCH 3/3] Remove remaining cleanups from c-exp.y Tom Tromey
2019-01-06  5:04   ` 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=20190105204112.26849-3-tom@tromey.com \
    --to=tom@tromey.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