]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove string-related cleanup from c-exp.y
authorTom Tromey <tom@tromey.com>
Thu, 3 Jan 2019 02:13:15 +0000 (19:13 -0700)
committerTom Tromey <tom@tromey.com>
Sun, 6 Jan 2019 16:39:33 +0000 (09:39 -0700)
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-06  Tom Tromey  <tom@tromey.com>

* c-exp.y (struct c_parse_state) <strings>: New member.
(operator_stoken): Update.

gdb/ChangeLog
gdb/c-exp.y

index 6ca534a0d24e94ad64fb54ca126e03bb86bb539b..57c758807536713af9f5da311f7e6cdeb18b09c4 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-06  Tom Tromey  <tom@tromey.com>
+
+       * c-exp.y (struct c_parse_state) <strings>: New member.
+       (operator_stoken): Update.
+
 2019-01-06  Tom Tromey  <tom@tromey.com>
 
        * parser-defs.h (type_ptr): Remove typedef.  Don't declare VEC.
index 54eb38935bdc30c90d49c7d9a2519396be23c12a..10e4ada5f043341f6403bc859d60ea192282b365 100644 (file)
@@ -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;
 };