aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-09-17 11:47:50 -0600
committerTom Tromey <tom@tromey.com>2020-09-17 11:58:56 -0600
commit88f07206fa577f80e8f6cfed7b2183dc3b4e9f39 (patch)
treec4c0fbb8469ed704a3fd82f2c22e498a5abec888
parent9519b2eea05637faa380a68fd679a950176de6db (diff)
downloadgdb-88f07206fa577f80e8f6cfed7b2183dc3b4e9f39.zip
gdb-88f07206fa577f80e8f6cfed7b2183dc3b4e9f39.tar.gz
gdb-88f07206fa577f80e8f6cfed7b2183dc3b4e9f39.tar.bz2
Use htab_up in auto-load.c
This changes auto-load.c to use htab_up, rather than manually calling htab_delete. gdb/ChangeLog 2020-09-17 Tom Tromey <tom@tromey.com> * auto-load.c (struct auto_load_pspace_info) <~auto_load_pspace_info, auto_load_pspace_info>: Remove. <loaded_script_files, loaded_script_texts>: Change type to htab_up. (~auto_load_pspace_info) Remove. (init_loaded_scripts_info, maybe_add_script_file) (maybe_add_script_text, auto_load_info_scripts): Update.
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/auto-load.c41
2 files changed, 26 insertions, 25 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f367709..e9b7b7d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2020-09-17 Tom Tromey <tom@tromey.com>
+
+ * auto-load.c (struct auto_load_pspace_info)
+ <~auto_load_pspace_info, auto_load_pspace_info>: Remove.
+ <loaded_script_files, loaded_script_texts>: Change type to
+ htab_up.
+ (~auto_load_pspace_info) Remove.
+ (init_loaded_scripts_info, maybe_add_script_file)
+ (maybe_add_script_text, auto_load_info_scripts): Update.
+
2020-09-17 Tom Tromey <tromey@adacore.com>
* c-exp.y (name_obstack): Now static.
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index c967261..9a51d2f 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -529,13 +529,10 @@ For more information about this security protection see the\n\
struct auto_load_pspace_info
{
- auto_load_pspace_info () = default;
- ~auto_load_pspace_info ();
-
/* For each program space we keep track of loaded scripts, both when
specified as file names and as scripts to be executed directly. */
- struct htab *loaded_script_files = nullptr;
- struct htab *loaded_script_texts = nullptr;
+ htab_up loaded_script_files;
+ htab_up loaded_script_texts;
/* Non-zero if we've issued the warning about an auto-load script not being
supported. We only want to issue this warning once. */
@@ -567,14 +564,6 @@ struct loaded_script
static const struct program_space_key<struct auto_load_pspace_info>
auto_load_pspace_data;
-auto_load_pspace_info::~auto_load_pspace_info ()
-{
- if (loaded_script_files)
- htab_delete (loaded_script_files);
- if (loaded_script_texts)
- htab_delete (loaded_script_texts);
-}
-
/* Get the current autoload data. If none is found yet, add it now. This
function always returns a valid object. */
@@ -621,14 +610,16 @@ init_loaded_scripts_info (struct auto_load_pspace_info *pspace_info)
Space for each entry is obtained with one malloc so we can free them
easily. */
- pspace_info->loaded_script_files = htab_create (31,
- hash_loaded_script_entry,
- eq_loaded_script_entry,
- xfree);
- pspace_info->loaded_script_texts = htab_create (31,
- hash_loaded_script_entry,
- eq_loaded_script_entry,
- xfree);
+ pspace_info->loaded_script_files.reset
+ (htab_create (31,
+ hash_loaded_script_entry,
+ eq_loaded_script_entry,
+ xfree));
+ pspace_info->loaded_script_texts.reset
+ (htab_create (31,
+ hash_loaded_script_entry,
+ eq_loaded_script_entry,
+ xfree));
pspace_info->unsupported_script_warning_printed = false;
pspace_info->script_not_found_warning_printed = false;
@@ -660,7 +651,7 @@ maybe_add_script_file (struct auto_load_pspace_info *pspace_info, int loaded,
const char *name, const char *full_path,
const struct extension_language_defn *language)
{
- struct htab *htab = pspace_info->loaded_script_files;
+ struct htab *htab = pspace_info->loaded_script_files.get ();
struct loaded_script **slot, entry;
int in_hash_table;
@@ -708,7 +699,7 @@ maybe_add_script_text (struct auto_load_pspace_info *pspace_info,
int loaded, const char *name,
const struct extension_language_defn *language)
{
- struct htab *htab = pspace_info->loaded_script_texts;
+ struct htab *htab = pspace_info->loaded_script_texts.get ();
struct loaded_script **slot, entry;
int in_hash_table;
@@ -1299,7 +1290,7 @@ auto_load_info_scripts (const char *pattern, int from_tty,
collect_matching_scripts_data data (&script_files, language);
/* Pass a pointer to scripts as VEC_safe_push can realloc space. */
- htab_traverse_noresize (pspace_info->loaded_script_files,
+ htab_traverse_noresize (pspace_info->loaded_script_files.get (),
collect_matching_scripts, &data);
std::sort (script_files.begin (), script_files.end (),
@@ -1311,7 +1302,7 @@ auto_load_info_scripts (const char *pattern, int from_tty,
collect_matching_scripts_data data (&script_texts, language);
/* Pass a pointer to scripts as VEC_safe_push can realloc space. */
- htab_traverse_noresize (pspace_info->loaded_script_texts,
+ htab_traverse_noresize (pspace_info->loaded_script_texts.get (),
collect_matching_scripts, &data);
std::sort (script_texts.begin (), script_texts.end (),