aboutsummaryrefslogtreecommitdiff
path: root/gdb/namespace.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-09-06 17:18:23 -0600
committerTom Tromey <tom@tromey.com>2017-09-09 14:10:51 -0600
commiteb1e02fd05688c28686a02f197c5e7cb0a5d6a27 (patch)
treeca15494cfc7a6c4c4a4addd3f67277249a682fd8 /gdb/namespace.c
parent0fc21fd8cf92de78c3c383378e70a2955e2631c3 (diff)
downloadgdb-eb1e02fd05688c28686a02f197c5e7cb0a5d6a27.zip
gdb-eb1e02fd05688c28686a02f197c5e7cb0a5d6a27.tar.gz
gdb-eb1e02fd05688c28686a02f197c5e7cb0a5d6a27.tar.bz2
Use std::vector in add_using_directive
This changes add_using_directive to accept a std::vector and then changes the callers. This allows removing a cleanup. ChangeLog 2017-09-09 Tom Tromey <tom@tromey.com> * namespace.h (add_using_directive): Update. * namespace.c (add_using_directive): Change type of excludes to std::vector. * dwarf2read.c (read_import_statement): Use std::vector. (read_namespace): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
Diffstat (limited to 'gdb/namespace.c')
-rw-r--r--gdb/namespace.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/gdb/namespace.c b/gdb/namespace.c
index 5ada813..a851ce9 100644
--- a/gdb/namespace.c
+++ b/gdb/namespace.c
@@ -39,7 +39,7 @@ add_using_directive (struct using_direct **using_directives,
const char *src,
const char *alias,
const char *declaration,
- VEC (const_char_ptr) *excludes,
+ const std::vector<const char *> &excludes,
int copy_names,
struct obstack *obstack)
{
@@ -52,7 +52,6 @@ add_using_directive (struct using_direct **using_directives,
for (current = *using_directives; current != NULL; current = current->next)
{
int ix;
- const char *param;
if (strcmp (current->import_src, src) != 0)
continue;
@@ -70,12 +69,11 @@ add_using_directive (struct using_direct **using_directives,
continue;
/* Compare the contents of EXCLUDES. */
- for (ix = 0; VEC_iterate (const_char_ptr, excludes, ix, param); ix++)
+ for (ix = 0; ix < excludes.size (); ++ix)
if (current->excludes[ix] == NULL
- || strcmp (param, current->excludes[ix]) != 0)
+ || strcmp (excludes[ix], current->excludes[ix]) != 0)
break;
- if (ix < VEC_length (const_char_ptr, excludes)
- || current->excludes[ix] != NULL)
+ if (ix < excludes.size () || current->excludes[ix] != NULL)
continue;
/* Parameters exactly match CURRENT. */
@@ -83,8 +81,7 @@ add_using_directive (struct using_direct **using_directives,
}
alloc_len = (sizeof(*newobj)
- + (VEC_length (const_char_ptr, excludes)
- * sizeof(*newobj->excludes)));
+ + (excludes.size () * sizeof(*newobj->excludes)));
newobj = (struct using_direct *) obstack_alloc (obstack, alloc_len);
memset (newobj, 0, sizeof (*newobj));
@@ -114,9 +111,9 @@ add_using_directive (struct using_direct **using_directives,
else
newobj->declaration = declaration;
- memcpy (newobj->excludes, VEC_address (const_char_ptr, excludes),
- VEC_length (const_char_ptr, excludes) * sizeof (*newobj->excludes));
- newobj->excludes[VEC_length (const_char_ptr, excludes)] = NULL;
+ memcpy (newobj->excludes, excludes.data (),
+ excludes.size () * sizeof (*newobj->excludes));
+ newobj->excludes[excludes.size ()] = NULL;
newobj->next = *using_directives;
*using_directives = newobj;