forked from Imagelibrary/binutils-gdb
Remove cleanup from add_path
This removes a cleanup from add_path, replacing it with a use of gdb::unique_xmalloc_ptr. Note that this declaration had to be hoisted somewhat, to avoid inteference from the "goto"s in this function. gdb/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> * source.c (add_path): Use gdb::unique_xmalloc_ptr.
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2018-09-13 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* source.c (add_path): Use gdb::unique_xmalloc_ptr.
|
||||||
|
|
||||||
2018-09-13 Simon Marchi <simon.marchi@ericsson.com>
|
2018-09-13 Simon Marchi <simon.marchi@ericsson.com>
|
||||||
2018-09-13 Tom Tromey <tom@tromey.com>
|
2018-09-13 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
|||||||
16
gdb/source.c
16
gdb/source.c
@@ -479,13 +479,12 @@ add_path (const char *dirname, char **which_path, int parse_separators)
|
|||||||
else
|
else
|
||||||
dir_vec.emplace_back (xstrdup (dirname));
|
dir_vec.emplace_back (xstrdup (dirname));
|
||||||
|
|
||||||
struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
|
|
||||||
|
|
||||||
for (const gdb::unique_xmalloc_ptr<char> &name_up : dir_vec)
|
for (const gdb::unique_xmalloc_ptr<char> &name_up : dir_vec)
|
||||||
{
|
{
|
||||||
char *name = name_up.get ();
|
char *name = name_up.get ();
|
||||||
char *p;
|
char *p;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
gdb::unique_xmalloc_ptr<char> new_name_holder;
|
||||||
|
|
||||||
/* Spaces and tabs will have been removed by buildargv().
|
/* Spaces and tabs will have been removed by buildargv().
|
||||||
NAME is the start of the directory.
|
NAME is the start of the directory.
|
||||||
@@ -531,16 +530,17 @@ add_path (const char *dirname, char **which_path, int parse_separators)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (name[0] == '~')
|
if (name[0] == '~')
|
||||||
name = tilde_expand (name);
|
new_name_holder.reset (tilde_expand (name));
|
||||||
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
|
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
|
||||||
else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */
|
else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */
|
||||||
name = concat (name, ".", (char *)NULL);
|
new_name_holder.reset (concat (name, ".", (char *) NULL));
|
||||||
#endif
|
#endif
|
||||||
else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$')
|
else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$')
|
||||||
name = concat (current_directory, SLASH_STRING, name, (char *)NULL);
|
new_name_holder.reset (concat (current_directory, SLASH_STRING, name,
|
||||||
|
(char *) NULL));
|
||||||
else
|
else
|
||||||
name = savestring (name, p - name);
|
new_name_holder.reset (savestring (name, p - name));
|
||||||
make_cleanup (xfree, name);
|
name = new_name_holder.get ();
|
||||||
|
|
||||||
/* Unless it's a variable, check existence. */
|
/* Unless it's a variable, check existence. */
|
||||||
if (name[0] != '$')
|
if (name[0] != '$')
|
||||||
@@ -630,8 +630,6 @@ add_path (const char *dirname, char **which_path, int parse_separators)
|
|||||||
skip_dup:
|
skip_dup:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
do_cleanups (back_to);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user