mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-10-17 12:53:17 +08:00
Make delim_string_to_char_ptr_vec return an std::vector
This patch makes delim_string_to_char_ptr_vec and all related functions use std::vector of gdb::unique_xmalloc_ptr. This allows getting rid of make_cleanup_free_char_ptr_vec. Returning a vector of unique_xmalloc_ptr instead of std::string allows to minimize the impacts on the calling code. We can evaluate later whether we could/should return a vector of std::strings instead. gdb/ChangeLog: * common/gdb_vecs.h (make_cleanup_free_char_ptr_vec): Remove. (delim_string_to_char_ptr_vec): Return std::vector of gdb::unique_xmalloc_ptr. (dirnames_to_char_ptr_vec_append): Take std::vector of gdb::unique_xmalloc_ptr. (dirnames_to_char_ptr_vec): Return std::vector of gdb::unique_xmalloc_ptr. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Take std::vector of gdb::unique_xmalloc_ptr, adjust the code. (delim_string_to_char_ptr_vec): Return an std::vector of gdb::unique_xmalloc_ptr, adjust the code. (dirnames_to_char_ptr_vec_append): Take an std::vector of gdb::unique_xmalloc_ptr, adjust the code. (dirnames_to_char_ptr_vec): Return an std::vector of gdb::unique_xmalloc_ptr, adjust the code. * auto-load.c (auto_load_safe_path_vec): Change type to std::vector of gdb::unique_xmalloc_ptr. (auto_load_expand_dir_vars): Return an std::vector of gdb::unique_xmalloc_ptr, adjust the code. (auto_load_safe_path_vec_update): Adjust. (filename_is_in_auto_load_safe_path_vec): Adjust. (auto_load_objfile_script_1): Adjust. * build-id.c (build_id_to_debug_bfd): Adjust. * linux-thread-db.c (thread_db_load_search): Adjust. * source.c (add_path): Adjust. (openp): Adjust. * symfile.c (find_separate_debug_file): Adjust. * utils.c (do_free_char_ptr_vec): Remove. (make_cleanup_free_char_ptr_vec): Remove. gdb/gdbserver/ChangeLog: * server.c (parse_debug_format_options): Adjust to delim_string_to_char_ptr_vec changes. * thread-db.c (thread_db_load_search): Adjust to dirnames_to_char_ptr_vec changes.
This commit is contained in:
24
gdb/utils.c
24
gdb/utils.c
@ -3052,30 +3052,6 @@ make_bpstat_clear_actions_cleanup (void)
|
||||
return make_cleanup (do_bpstat_clear_actions_cleanup, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* Helper for make_cleanup_free_char_ptr_vec. */
|
||||
|
||||
static void
|
||||
do_free_char_ptr_vec (void *arg)
|
||||
{
|
||||
VEC (char_ptr) *char_ptr_vec = (VEC (char_ptr) *) arg;
|
||||
|
||||
free_char_ptr_vec (char_ptr_vec);
|
||||
}
|
||||
|
||||
/* Make cleanup handler calling xfree for each element of CHAR_PTR_VEC and
|
||||
final VEC_free for CHAR_PTR_VEC itself.
|
||||
|
||||
You must not modify CHAR_PTR_VEC after this cleanup registration as the
|
||||
CHAR_PTR_VEC base address may change on its updates. Contrary to VEC_free
|
||||
this function does not (cannot) clear the pointer. */
|
||||
|
||||
struct cleanup *
|
||||
make_cleanup_free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec)
|
||||
{
|
||||
return make_cleanup (do_free_char_ptr_vec, char_ptr_vec);
|
||||
}
|
||||
|
||||
/* Substitute all occurences of string FROM by string TO in *STRINGP. *STRINGP
|
||||
must come from xrealloc-compatible allocator and it may be updated. FROM
|
||||
needs to be delimited by IS_DIR_SEPARATOR or DIRNAME_SEPARATOR (or be
|
||||
|
Reference in New Issue
Block a user