From: Tom Tromey Date: Sun, 24 Oct 2021 21:58:24 +0000 (-0600) Subject: Remove an xfree from add_path X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c0390cb8c10d809d5abf86b190aa6f59f2891b28;p=binutils-gdb.git Remove an xfree from add_path This removes a temporary \0 assignment and an xfree from add_path, replacing it with a simpler use of std::string. --- diff --git a/gdb/source.c b/gdb/source.c index 3810af83042..d91389e28b7 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -660,15 +660,10 @@ add_path (const char *dirname, char **which_path, int parse_separators) more. */ if (prefix) { - char *temp, c; - - c = old[prefix]; - old[prefix] = '\0'; - temp = concat (old, tinybuf, name, (char *)NULL); - old[prefix] = c; - *which_path = concat (temp, "", &old[prefix], (char *) NULL); - prefix = strlen (temp); - xfree (temp); + std::string temp (old, prefix); + *which_path = concat (temp.c_str (), tinybuf, name, &old[prefix], + (char *) nullptr); + prefix = temp.length (); } else {