aboutsummaryrefslogtreecommitdiff
path: root/gdb/common
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/common')
-rw-r--r--gdb/common/gdb_vecs.c36
-rw-r--r--gdb/common/gdb_vecs.h24
2 files changed, 31 insertions, 29 deletions
diff --git a/gdb/common/gdb_vecs.c b/gdb/common/gdb_vecs.c
index a221460..a19d238 100644
--- a/gdb/common/gdb_vecs.c
+++ b/gdb/common/gdb_vecs.c
@@ -40,11 +40,12 @@ free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec)
}
/* Worker function to split character delimiter separated string of fields
- STR into a CHAR_PTR_VEC. */
+ STR into a char pointer vector. */
static void
-delim_string_to_char_ptr_vec_append (VEC (char_ptr) **vecp,
- const char *str, char delimiter)
+delim_string_to_char_ptr_vec_append
+ (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *str,
+ char delimiter)
{
do
{
@@ -64,49 +65,40 @@ delim_string_to_char_ptr_vec_append (VEC (char_ptr) **vecp,
this_field = (char *) xmalloc (this_len + 1);
memcpy (this_field, str, this_len);
this_field[this_len] = '\0';
- VEC_safe_push (char_ptr, *vecp, this_field);
+ vecp->emplace_back (this_field);
str = next_field;
}
while (str != NULL);
}
-/* Split STR, a list of DELIMITER-separated fields, into a CHAR_PTR_VEC.
+/* See gdb_vecs.h. */
- You may modify the returned strings.
- Read free_char_ptr_vec for its cleanup. */
-
-VEC (char_ptr) *
+std::vector<gdb::unique_xmalloc_ptr<char>>
delim_string_to_char_ptr_vec (const char *str, char delimiter)
{
- VEC (char_ptr) *retval = NULL;
+ std::vector<gdb::unique_xmalloc_ptr<char>> retval;
delim_string_to_char_ptr_vec_append (&retval, str, delimiter);
return retval;
}
-/* Extended version of dirnames_to_char_ptr_vec - additionally if *VECP is
- non-NULL the new list elements from DIRNAMES are appended to the existing
- *VECP list of entries. *VECP address will be updated by this call. */
+/* See gdb_vecs.h. */
void
-dirnames_to_char_ptr_vec_append (VEC (char_ptr) **vecp, const char *dirnames)
+dirnames_to_char_ptr_vec_append
+ (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames)
{
delim_string_to_char_ptr_vec_append (vecp, dirnames, DIRNAME_SEPARATOR);
}
-/* Split DIRNAMES by DIRNAME_SEPARATOR delimiter and return a list of all the
- elements in their original order. For empty string ("") DIRNAMES return
- list of one empty string ("") element.
-
- You may modify the returned strings.
- Read free_char_ptr_vec for its cleanup. */
+/* See gdb_vecs.h. */
-VEC (char_ptr) *
+std::vector<gdb::unique_xmalloc_ptr<char>>
dirnames_to_char_ptr_vec (const char *dirnames)
{
- VEC (char_ptr) *retval = NULL;
+ std::vector<gdb::unique_xmalloc_ptr<char>> retval;
dirnames_to_char_ptr_vec_append (&retval, dirnames);
diff --git a/gdb/common/gdb_vecs.h b/gdb/common/gdb_vecs.h
index 75caf59..17ed06c 100644
--- a/gdb/common/gdb_vecs.h
+++ b/gdb/common/gdb_vecs.h
@@ -31,15 +31,25 @@ DEF_VEC_P (const_char_ptr);
extern void free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec);
-extern struct cleanup *
- make_cleanup_free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec);
+/* Split STR, a list of DELIMITER-separated fields, into a char pointer vector.
-extern VEC (char_ptr) *delim_string_to_char_ptr_vec (const char *str,
- char delimiter);
+ You may modify the returned strings. */
-extern void dirnames_to_char_ptr_vec_append (VEC (char_ptr) **vecp,
- const char *dirnames);
+extern std::vector<gdb::unique_xmalloc_ptr<char>>
+ delim_string_to_char_ptr_vec (const char *str, char delimiter);
-extern VEC (char_ptr) *dirnames_to_char_ptr_vec (const char *dirnames);
+/* Like dirnames_to_char_ptr_vec, but append the directories to *VECP. */
+
+extern void dirnames_to_char_ptr_vec_append
+ (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames);
+
+/* Split DIRNAMES by DIRNAME_SEPARATOR delimiter and return a list of all the
+ elements in their original order. For empty string ("") DIRNAMES return
+ list of one empty string ("") element.
+
+ You may modify the returned strings. */
+
+extern std::vector<gdb::unique_xmalloc_ptr<char>>
+ dirnames_to_char_ptr_vec (const char *dirnames);
#endif /* GDB_VECS_H */