aboutsummaryrefslogtreecommitdiff
path: root/gdb/compile/compile-c-support.c
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2018-08-10 10:38:56 -0700
committerKeith Seitz <keiths@redhat.com>2018-08-10 11:14:25 -0700
commitbd923e510884a92514a4f9d90d79592d248d5d92 (patch)
tree95c8395b4e3c64552a5f6d6cbf9ca9db08e592a4 /gdb/compile/compile-c-support.c
parentd7f449c026181e14162a67407842462e4bc0d8bd (diff)
downloadgdb-bd923e510884a92514a4f9d90d79592d248d5d92.zip
gdb-bd923e510884a92514a4f9d90d79592d248d5d92.tar.gz
gdb-bd923e510884a92514a4f9d90d79592d248d5d92.tar.bz2
Return unique_xmalloc_ptr for generate_c_for_variable_locations
This patch eliminates two cleanups in compile/ by changing generate_c_for_variable_locations so that it returns a unique_ptr. gdb/ChangeLog: * compile/compile-c-support.c (c_compute_program): Use unique_xmalloc_ptr to eliminate cleanup. * compile/compile-c-symbols.c (generate_c_for_variable_locations): Return a unique_xmalloc_ptr and eliminate cleanup. * compile/compile-internal.h (generate_c_for_variable_locations): Return unique_xmalloc_ptr and update description.
Diffstat (limited to 'gdb/compile/compile-c-support.c')
-rw-r--r--gdb/compile/compile-c-support.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c
index e694648..696bb9f 100644
--- a/gdb/compile/compile-c-support.c
+++ b/gdb/compile/compile-c-support.c
@@ -351,17 +351,15 @@ c_compute_program (struct compile_instance *inst,
and the user's code may only refer to globals. */
if (inst->scope != COMPILE_I_RAW_SCOPE)
{
- unsigned char *registers_used;
int i;
/* Generate the code to compute variable locations, but do it
before generating the function header, so we can define the
register struct before the function body. This requires a
temporary stream. */
- registers_used = generate_c_for_variable_locations (context,
- var_stream, gdbarch,
- expr_block, expr_pc);
- make_cleanup (xfree, registers_used);
+ gdb::unique_xmalloc_ptr<unsigned char> registers_used
+ = generate_c_for_variable_locations (context, var_stream, gdbarch,
+ expr_block, expr_pc);
buf.puts ("typedef unsigned int"
" __attribute__ ((__mode__(__pointer__)))"
@@ -382,7 +380,7 @@ c_compute_program (struct compile_instance *inst,
mode, mode);
}
- generate_register_struct (&buf, gdbarch, registers_used);
+ generate_register_struct (&buf, gdbarch, registers_used.get ());
}
add_code_header (inst->scope, &buf);