aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-registers.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-07-22 14:57:55 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-07-22 16:09:16 +0100
commita67a1c41fe4ab9bd8b1dcb7d5f68e080a0e96dfe (patch)
tree42b836fae3e703bbc10120fdadd46c6e15eeca19 /gdb/python/py-registers.c
parentdf16e041deafa1d7fe7d8e65c02213b885c60a8e (diff)
downloadgdb-a67a1c41fe4ab9bd8b1dcb7d5f68e080a0e96dfe.zip
gdb-a67a1c41fe4ab9bd8b1dcb7d5f68e080a0e96dfe.tar.gz
gdb-a67a1c41fe4ab9bd8b1dcb7d5f68e080a0e96dfe.tar.bz2
gdb/python: Use reference not pointer in py-registers.c
Pedro's review comments arrived after I'd already committed this change: commit f7306dac19c502232f766c3881313857915f330d Date: Tue Jul 7 15:00:30 2020 +0100 gdb/python: Reuse gdb.RegisterDescriptor objects where possible See: https://sourceware.org/pipermail/gdb-patches/2020-July/170726.html There should be no user visible changes after this commit. gdb/ChangeLog: * python/py-registers.c (gdbpy_register_object_data_init): Remove redundant local variable. (gdbpy_get_register_descriptor): Extract descriptor vector as a reference, not pointer, update code accordingly.
Diffstat (limited to 'gdb/python/py-registers.c')
-rw-r--r--gdb/python/py-registers.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c
index 9396498..f64ca3c 100644
--- a/gdb/python/py-registers.c
+++ b/gdb/python/py-registers.c
@@ -92,8 +92,7 @@ extern PyTypeObject reggroup_object_type
static void *
gdbpy_register_object_data_init (struct gdbarch *gdbarch)
{
- std::vector<gdbpy_ref<>> *vec = new (std::vector<gdbpy_ref<>>);
- return (void *) vec;
+ return new std::vector<gdbpy_ref<>>;
}
/* Return a gdb.RegisterGroup object wrapping REGGROUP. The register
@@ -158,16 +157,17 @@ static gdbpy_ref<>
gdbpy_get_register_descriptor (struct gdbarch *gdbarch,
int regnum)
{
- auto vec = (std::vector<gdbpy_ref<>> *) gdbarch_data
- (gdbarch, gdbpy_register_object_data);
+ auto &vec
+ = *(std::vector<gdbpy_ref<>> *) gdbarch_data (gdbarch,
+ gdbpy_register_object_data);
/* Ensure that we have enough entries in the vector. */
- if (vec->size () <= regnum)
- vec->resize ((regnum + 1), nullptr);
+ if (vec.size () <= regnum)
+ vec.resize ((regnum + 1), nullptr);
/* If we don't already have a descriptor for REGNUM in GDBARCH then
create one now. */
- if (vec->at (regnum) == nullptr)
+ if (vec[regnum] == nullptr)
{
gdbpy_ref <register_descriptor_object> reg
(PyObject_New (register_descriptor_object,
@@ -176,12 +176,12 @@ gdbpy_get_register_descriptor (struct gdbarch *gdbarch,
return NULL;
reg->regnum = regnum;
reg->gdbarch = gdbarch;
- vec->at (regnum) = gdbpy_ref<> ((PyObject *) reg.release ());
+ vec[regnum] = gdbpy_ref<> ((PyObject *) reg.release ());
}
/* Grab the register descriptor from the vector, the reference count is
automatically incremented thanks to gdbpy_ref. */
- return vec->at (regnum);
+ return vec[regnum];
}
/* Convert the register descriptor to a string. */