summaryrefslogtreecommitdiff
path: root/gdb/auto-load.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-02-08 12:06:44 -0700
committerTom Tromey <tom@tromey.com>2018-02-09 05:53:21 -0700
commita37a2ae7080898244de86d136961de81fe28a434 (patch)
tree5768ea23e9f3c344f19c0841d50c90826a71d55e /gdb/auto-load.c
parent4e7253479941cd6d59a0c8efbb1113d3734b7f56 (diff)
downloadbinutils-gdb-a37a2ae7080898244de86d136961de81fe28a434.tar.gz
Use std::string in execute_script_contents
This changes execute_script_contents to use a std::string, allowing the removal of a cleanup. 2018-02-09 Tom Tromey <tom@tromey.com> * auto-load.c (execute_script_contents): Use std::string.
Diffstat (limited to 'gdb/auto-load.c')
-rw-r--r--gdb/auto-load.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 30c8b89e8eb..1f3d366a563 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -989,23 +989,21 @@ execute_script_contents (struct auto_load_pspace_info *pspace_info,
{
objfile_script_executor_func *executor;
const char *newline, *script_text;
- char *name;
+ const char *name;
int is_safe, in_hash_table;
- struct cleanup *cleanups;
-
- cleanups = make_cleanup (null_cleanup, NULL);
/* The first line of the script is the name of the script.
It must not contain any kind of space character. */
name = NULL;
newline = strchr (script, '\n');
+ std::string name_holder;
if (newline != NULL)
{
- char *buf, *p;
+ const char *buf, *p;
/* Put the name in a buffer and validate it. */
- buf = xstrndup (script, newline - script);
- make_cleanup (xfree, buf);
+ name_holder = std::string (script, newline - script);
+ buf = name_holder.c_str ();
for (p = buf; *p != '\0'; ++p)
{
if (isspace (*p))
@@ -1022,7 +1020,6 @@ execute_script_contents (struct auto_load_pspace_info *pspace_info,
Missing/bad script name in entry at offset %u in section %s\n\
of file %s."),
offset, section_name, objfile_name (objfile));
- do_cleanups (cleanups);
return;
}
script_text = newline + 1;
@@ -1035,7 +1032,6 @@ of file %s."),
maybe_print_unsupported_script_warning (pspace_info, objfile, language,
section_name, offset);
maybe_add_script_text (pspace_info, 0, name, language);
- do_cleanups (cleanups);
return;
}
@@ -1043,7 +1039,6 @@ of file %s."),
if (!ext_lang_auto_load_enabled (language))
{
/* No message is printed, just skip it. */
- do_cleanups (cleanups);
return;
}
@@ -1059,8 +1054,6 @@ of file %s."),
/* If this file is not currently loaded, load it. */
if (is_safe && !in_hash_table)
executor (language, objfile, name, script_text);
-
- do_cleanups (cleanups);
}
/* Load scripts specified in OBJFILE.