aboutsummaryrefslogtreecommitdiff
path: root/gdb/jit.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2019-12-12 14:54:47 -0500
committerSimon Marchi <simon.marchi@efficios.com>2019-12-12 14:54:47 -0500
commit7190276c52b9d86a52aae73d3a0f8b56e7a1f4f1 (patch)
treeb08bc114ee4318c14995078880e10063d8a592ad /gdb/jit.c
parentd61df89700bcf1633ca9db0ea403c2108c3cac3e (diff)
downloadgdb-7190276c52b9d86a52aae73d3a0f8b56e7a1f4f1.zip
gdb-7190276c52b9d86a52aae73d3a0f8b56e7a1f4f1.tar.gz
gdb-7190276c52b9d86a52aae73d3a0f8b56e7a1f4f1.tar.bz2
Replace xmalloc/xfree with vector in jit.c
I'm currently studying that code and noticed this manual memory management, which could easily be replaced with a vector, so here it is. gdb/ChangeLog: * jit.c (jit_reader_try_read_symtab): Replace xmalloc/xfree with gdb::byte_vector.
Diffstat (limited to 'gdb/jit.c')
-rw-r--r--gdb/jit.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/gdb/jit.c b/gdb/jit.c
index 480b459..b6e51e4 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -808,7 +808,6 @@ static int
jit_reader_try_read_symtab (struct jit_code_entry *code_entry,
CORE_ADDR entry_addr)
{
- gdb_byte *gdb_mem;
int status;
jit_dbg_reader_data priv_data;
struct gdb_reader_funcs *funcs;
@@ -831,12 +830,12 @@ jit_reader_try_read_symtab (struct jit_code_entry *code_entry,
if (!loaded_jit_reader)
return 0;
- gdb_mem = (gdb_byte *) xmalloc (code_entry->symfile_size);
+ gdb::byte_vector gdb_mem (code_entry->symfile_size);
status = 1;
try
{
- if (target_read_memory (code_entry->symfile_addr, gdb_mem,
+ if (target_read_memory (code_entry->symfile_addr, gdb_mem.data (),
code_entry->symfile_size))
status = 0;
}
@@ -848,12 +847,12 @@ jit_reader_try_read_symtab (struct jit_code_entry *code_entry,
if (status)
{
funcs = loaded_jit_reader->functions;
- if (funcs->read (funcs, &callbacks, gdb_mem, code_entry->symfile_size)
+ if (funcs->read (funcs, &callbacks, gdb_mem.data (),
+ code_entry->symfile_size)
!= GDB_SUCCESS)
status = 0;
}
- xfree (gdb_mem);
if (jit_debug && status == 0)
fprintf_unfiltered (gdb_stdlog,
"Could not read symtab using the loaded JIT reader.\n");