aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-09-22 21:32:03 -0600
committerTom Tromey <tom@tromey.com>2016-10-12 19:43:16 -0600
commit816d7b53047bca81c226990bc9248d59d80d4b8b (patch)
tree6ce4862146d591338a8f9c33375bff4c9bc0b24c
parentbfd282882d534cd4f48e2fc29d4ce0923c52352b (diff)
downloadgdb-816d7b53047bca81c226990bc9248d59d80d4b8b.zip
gdb-816d7b53047bca81c226990bc9248d59d80d4b8b.tar.gz
gdb-816d7b53047bca81c226990bc9248d59d80d4b8b.tar.bz2
Change selttest.c to use use std::vector
This patch changes selftest.c to use std::vector rather than VEC. I think this is a small net plus. 2016-10-12 Tom Tromey <tom@tromey.com> * selftest.c: Include <vector>, not "vec.h". (self_test_function_ptr): Remove. (tests): Now a std::vector. (register_self_test, run_self_tests): Update.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/selftest.c20
2 files changed, 14 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2a9352a..7507648 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2016-10-12 Tom Tromey <tom@tromey.com>
+
+ * selftest.c: Include <vector>, not "vec.h".
+ (self_test_function_ptr): Remove.
+ (tests): Now a std::vector.
+ (register_self_test, run_self_tests): Update.
+
2016-10-13 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
diff --git a/gdb/selftest.c b/gdb/selftest.c
index c63c06d..110b9e5 100644
--- a/gdb/selftest.c
+++ b/gdb/selftest.c
@@ -18,22 +18,18 @@
#include "defs.h"
#include "selftest.h"
-#include "vec.h"
-
-typedef self_test_function *self_test_function_ptr;
-
-DEF_VEC_P (self_test_function_ptr);
+#include <vector>
/* All the tests that have been registered. */
-static VEC (self_test_function_ptr) *tests;
+static std::vector<self_test_function *> tests;
/* See selftest.h. */
void
register_self_test (self_test_function *function)
{
- VEC_safe_push (self_test_function_ptr, tests, function);
+ tests.push_back (function);
}
/* See selftest.h. */
@@ -41,17 +37,15 @@ register_self_test (self_test_function *function)
void
run_self_tests (void)
{
- int i;
- self_test_function_ptr func;
int failed = 0;
- for (i = 0; VEC_iterate (self_test_function_ptr, tests, i, func); ++i)
+ for (int i = 0; i < tests.size (); ++i)
{
QUIT;
TRY
{
- (*func) ();
+ tests[i] ();
}
CATCH (ex, RETURN_MASK_ERROR)
{
@@ -62,6 +56,6 @@ run_self_tests (void)
END_CATCH
}
- printf_filtered (_("Ran %u unit tests, %d failed\n"),
- VEC_length (self_test_function_ptr, tests), failed);
+ printf_filtered (_("Ran %lu unit tests, %d failed\n"),
+ (long) tests.size (), failed);
}