(allocate_piece_closure): Initialize refc.
(copy_pieced_value_closure): Use refc.
(free_pieced_value_closure): Likewise.
+2010-05-27 Tom Tromey <tromey@redhat.com>
+
+ * dwarf2loc.c (struct piece_closure) <refc>: New field.
+ (allocate_piece_closure): Initialize refc.
+ (copy_pieced_value_closure): Use refc.
+ (free_pieced_value_closure): Likewise.
+
2010-05-27 Tom Tromey <tromey@redhat.com>
* arm-tdep.c (push_stack_item): 'contents' now const.
struct piece_closure
{
+ /* Reference count. */
+ int refc;
+
/* The number of pieces used to describe this variable. */
int n_pieces;
{
struct piece_closure *c = XZALLOC (struct piece_closure);
+ c->refc = 1;
c->n_pieces = n_pieces;
c->addr_size = addr_size;
c->pieces = XCALLOC (n_pieces, struct dwarf_expr_piece);
{
struct piece_closure *c = (struct piece_closure *) value_computed_closure (v);
- return allocate_piece_closure (c->n_pieces, c->pieces, c->addr_size);
+ ++c->refc;
+ return c;
}
static void
{
struct piece_closure *c = (struct piece_closure *) value_computed_closure (v);
- xfree (c->pieces);
- xfree (c);
+ --c->refc;
+ if (c->refc == 0)
+ {
+ xfree (c->pieces);
+ xfree (c);
+ }
}
/* Functions for accessing a variable described by DW_OP_piece. */