diff options
author | Keith Seitz <keiths@redhat.com> | 2018-08-10 10:38:56 -0700 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2018-08-10 11:14:25 -0700 |
commit | bd923e510884a92514a4f9d90d79592d248d5d92 (patch) | |
tree | 95c8395b4e3c64552a5f6d6cbf9ca9db08e592a4 /gdb/compile/compile-c-symbols.c | |
parent | d7f449c026181e14162a67407842462e4bc0d8bd (diff) | |
download | gdb-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-symbols.c')
-rw-r--r-- | gdb/compile/compile-c-symbols.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 43de7df..6987fa3 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -708,24 +708,22 @@ generate_c_for_for_one_variable (struct compile_c_instance *compiler, /* See compile-internal.h. */ -unsigned char * +gdb::unique_xmalloc_ptr<unsigned char> generate_c_for_variable_locations (struct compile_c_instance *compiler, string_file &stream, struct gdbarch *gdbarch, const struct block *block, CORE_ADDR pc) { - struct cleanup *outer; const struct block *static_block = block_static_block (block); - unsigned char *registers_used; /* If we're already in the static or global block, there is nothing to write. */ if (static_block == NULL || block == static_block) return NULL; - registers_used = XCNEWVEC (unsigned char, gdbarch_num_regs (gdbarch)); - outer = make_cleanup (xfree, registers_used); + gdb::unique_xmalloc_ptr<unsigned char> registers_used + (XCNEWVEC (unsigned char, gdbarch_num_regs (gdbarch))); /* Ensure that a given name is only entered once. This reflects the reality of shadowing. */ @@ -745,7 +743,7 @@ generate_c_for_variable_locations (struct compile_c_instance *compiler, { if (!symbol_seen (symhash.get (), sym)) generate_c_for_for_one_variable (compiler, stream, gdbarch, - registers_used, pc, sym); + registers_used.get (), pc, sym); } /* If we just finished the outermost block of a function, we're @@ -755,6 +753,5 @@ generate_c_for_variable_locations (struct compile_c_instance *compiler, block = BLOCK_SUPERBLOCK (block); } - discard_cleanups (outer); return registers_used; } |