aboutsummaryrefslogtreecommitdiff
path: root/gdb/common
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2018-04-09 15:40:45 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2018-04-09 15:40:45 -0400
commitb24531ed171b5751a3a64c461728c9ad62092c8a (patch)
treedb3fdd6625a99c6e20202c6493573a7914f93c2d /gdb/common
parentc252925ccc8c3c2ce2a65d12a50acfee53914ce3 (diff)
downloadgdb-b24531ed171b5751a3a64c461728c9ad62092c8a.zip
gdb-b24531ed171b5751a3a64c461728c9ad62092c8a.tar.gz
gdb-b24531ed171b5751a3a64c461728c9ad62092c8a.tar.bz2
Use an std::vector for inline_states
This patch replaces VEC(inline_state) with std::vector<inline_state> and adjusts the code that uses it. gdb/ChangeLog: * common/gdb_vecs.h (unordered_remove): Add overload that takes an iterator. * inline-frame.c: Include <algorithm>. (struct inline_state): Add constructor. (inline_state_s): Remove. (DEF_VEC_O(inline_state_s)): Remove. (inline_states): Change type to std::vector. (find_inline_frame_state): Adjust to std::vector. (allocate_inline_frame_state): Remove. (clear_inline_frame_state): Adjust to std::vector. (skip_inline_frames): Adjust to std::vector.
Diffstat (limited to 'gdb/common')
-rw-r--r--gdb/common/gdb_vecs.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/gdb/common/gdb_vecs.h b/gdb/common/gdb_vecs.h
index 141d05e..3e461dc 100644
--- a/gdb/common/gdb_vecs.h
+++ b/gdb/common/gdb_vecs.h
@@ -47,6 +47,22 @@ extern void dirnames_to_char_ptr_vec_append
extern std::vector<gdb::unique_xmalloc_ptr<char>>
dirnames_to_char_ptr_vec (const char *dirnames);
+/* Remove the element pointed by iterator IT from VEC, not preserving the order
+ of the remaining elements. Return the removed element. */
+
+template <typename T>
+T
+unordered_remove (std::vector<T> &vec, typename std::vector<T>::iterator it)
+{
+ gdb_assert (it >= vec.begin () && it < vec.end ());
+
+ T removed = std::move (*it);
+ *it = std::move (vec.back ());
+ vec.pop_back ();
+
+ return removed;
+}
+
/* Remove the element at position IX from VEC, not preserving the order of the
remaining elements. Return the removed element. */
@@ -56,11 +72,7 @@ unordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
{
gdb_assert (ix < vec.size ());
- T removed = std::move (vec[ix]);
- vec[ix] = std::move (vec.back ());
- vec.pop_back ();
-
- return removed;
+ return unordered_remove (vec, vec.begin () + ix);
}
/* Remove the element at position IX from VEC, preserving the order the