diff options
author | Tom Tromey <tom@tromey.com> | 2020-12-01 17:22:05 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-12-01 17:22:05 -0700 |
commit | 77bf7e991150d3fac70294910c027c43ae5789b6 (patch) | |
tree | 058346ea2f9e4daafe97d4d1784aaabca585b216 /gdb/expression.h | |
parent | e89b3d52936a0492f2886c2a1fc53dd87aaf94a3 (diff) | |
download | binutils-77bf7e991150d3fac70294910c027c43ae5789b6.zip binutils-77bf7e991150d3fac70294910c027c43ae5789b6.tar.gz binutils-77bf7e991150d3fac70294910c027c43ae5789b6.tar.bz2 |
Use new+delete for struct expression
In another series I'm working on, it is necessary to manage
"struct expression" with new and delete. Because the patch is
straightforward and could be extracted, I've done so here.
gdb/ChangeLog
2020-12-01 Tom Tromey <tom@tromey.com>
* parse.c (expr_builder::expr_builder): Initialize expout.
(expr_builder::release): Use expression::resize.
(expression::expression, expression::~expression)
(expression::resize): New methods.
(write_exp_elt): Use expression::resize.
(prefixify_expression): Update.
(increase_expout_size): Use expression::resize.
* expression.h (struct expression): Add constructor, destructor.
<resize>: New method.
(expression_up): Change type.
Diffstat (limited to 'gdb/expression.h')
-rw-r--r-- | gdb/expression.h | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/gdb/expression.h b/gdb/expression.h index a8bfac1..684274b 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -93,15 +93,22 @@ union exp_element }; struct expression - { - const struct language_defn *language_defn; /* language it was - entered in. */ - struct gdbarch *gdbarch; /* architecture it was parsed in. */ - int nelts; - union exp_element elts[1]; - }; +{ + expression (const struct language_defn *, struct gdbarch *, size_t); + ~expression (); + DISABLE_COPY_AND_ASSIGN (expression); + + void resize (size_t); + + /* Language it was entered in. */ + const struct language_defn *language_defn; + /* Architecture it was parsed in. */ + struct gdbarch *gdbarch; + int nelts = 0; + union exp_element *elts; +}; -typedef gdb::unique_xmalloc_ptr<expression> expression_up; +typedef std::unique_ptr<expression> expression_up; /* Macros for converting between number of expression elements and bytes to store that many expression elements. */ |