summaryrefslogtreecommitdiff
path: root/gdb/selftest-arch.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-08-09 21:47:02 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-08-12 15:20:26 -0400
commit9b1f59fc95da32963f3ba22f8587ea0c12899e05 (patch)
tree27ece8ea76f043dec5c489e0055047c068144df7 /gdb/selftest-arch.c
parent65f82b1972cca3476b3ef6abf1d9923d34f5d4f5 (diff)
downloadbinutils-gdb-9b1f59fc95da32963f3ba22f8587ea0c12899e05.tar.gz
gdb: make gdbarch_printable_names return a vector
I noticed that gdbarch_selftest::operator() leaked the value returned by gdbarch_printable_names. Make gdbarch_printable_names return an std::vector and update callers. That makes it easier for everyone involved, less manual memory management. Change-Id: Ia8fc028bdb91f787410cca34f10bf3c5a6da1498
Diffstat (limited to 'gdb/selftest-arch.c')
-rw-r--r--gdb/selftest-arch.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/gdb/selftest-arch.c b/gdb/selftest-arch.c
index 0eef134d484..052daed9196 100644
--- a/gdb/selftest-arch.c
+++ b/gdb/selftest-arch.c
@@ -36,23 +36,23 @@ struct gdbarch_selftest : public selftest
void operator() () const override
{
- const char **arches = gdbarch_printable_names ();
+ std::vector<const char *> arches = gdbarch_printable_names ();
bool pass = true;
- for (int i = 0; arches[i] != NULL; i++)
+ for (const char *arch : arches)
{
- if (strcmp ("fr300", arches[i]) == 0)
+ if (strcmp ("fr300", arch) == 0)
{
/* PR 20946 */
continue;
}
- else if (strcmp ("powerpc:EC603e", arches[i]) == 0
- || strcmp ("powerpc:e500mc", arches[i]) == 0
- || strcmp ("powerpc:e500mc64", arches[i]) == 0
- || strcmp ("powerpc:titan", arches[i]) == 0
- || strcmp ("powerpc:vle", arches[i]) == 0
- || strcmp ("powerpc:e5500", arches[i]) == 0
- || strcmp ("powerpc:e6500", arches[i]) == 0)
+ else if (strcmp ("powerpc:EC603e", arch) == 0
+ || strcmp ("powerpc:e500mc", arch) == 0
+ || strcmp ("powerpc:e500mc64", arch) == 0
+ || strcmp ("powerpc:titan", arch) == 0
+ || strcmp ("powerpc:vle", arch) == 0
+ || strcmp ("powerpc:e5500", arch) == 0
+ || strcmp ("powerpc:e6500", arch) == 0)
{
/* PR 19797 */
continue;
@@ -64,7 +64,7 @@ struct gdbarch_selftest : public selftest
{
struct gdbarch_info info;
- info.bfd_arch_info = bfd_scan_arch (arches[i]);
+ info.bfd_arch_info = bfd_scan_arch (arch);
struct gdbarch *gdbarch = gdbarch_find_by_info (info);
SELF_CHECK (gdbarch != NULL);
@@ -75,7 +75,7 @@ struct gdbarch_selftest : public selftest
{
pass = false;
exception_fprintf (gdb_stderr, ex,
- _("Self test failed: arch %s: "), arches[i]);
+ _("Self test failed: arch %s: "), arch);
}
reset ();