mirror of git://gcc.gnu.org/git/gcc.git
incpath.c (add_standard_paths): Use reconcat instead of concat where appropriate and avoid leaking memory.
* incpath.c (add_standard_paths): Use reconcat instead of concat where appropriate and avoid leaking memory. From-SVN: r196306
This commit is contained in:
parent
dc3577989d
commit
0fcb564b72
|
|
@ -1,5 +1,8 @@
|
||||||
2013-02-27 Jakub Jelinek <jakub@redhat.com>
|
2013-02-27 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
* incpath.c (add_standard_paths): Use reconcat instead of concat
|
||||||
|
where appropriate and avoid leaking memory.
|
||||||
|
|
||||||
* opts.h: Include obstack.h.
|
* opts.h: Include obstack.h.
|
||||||
(opts_concat): New prototype.
|
(opts_concat): New prototype.
|
||||||
(opts_obstack): New declaration.
|
(opts_obstack): New declaration.
|
||||||
|
|
|
||||||
|
|
@ -149,12 +149,17 @@ add_standard_paths (const char *sysroot, const char *iprefix,
|
||||||
{
|
{
|
||||||
char *str = concat (iprefix, p->fname + len, NULL);
|
char *str = concat (iprefix, p->fname + len, NULL);
|
||||||
if (p->multilib == 1 && imultilib)
|
if (p->multilib == 1 && imultilib)
|
||||||
str = concat (str, dir_separator_str, imultilib, NULL);
|
str = reconcat (str, str, dir_separator_str,
|
||||||
|
imultilib, NULL);
|
||||||
else if (p->multilib == 2)
|
else if (p->multilib == 2)
|
||||||
{
|
{
|
||||||
if (!imultiarch)
|
if (!imultiarch)
|
||||||
continue;
|
{
|
||||||
str = concat (str, dir_separator_str, imultiarch, NULL);
|
free (str);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
str = reconcat (str, str, dir_separator_str,
|
||||||
|
imultiarch, NULL);
|
||||||
}
|
}
|
||||||
add_path (str, SYSTEM, p->cxx_aware, false);
|
add_path (str, SYSTEM, p->cxx_aware, false);
|
||||||
}
|
}
|
||||||
|
|
@ -183,6 +188,7 @@ add_standard_paths (const char *sysroot, const char *iprefix,
|
||||||
&& !filename_ncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len))
|
&& !filename_ncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len))
|
||||||
{
|
{
|
||||||
static const char *relocated_prefix;
|
static const char *relocated_prefix;
|
||||||
|
char *ostr;
|
||||||
/* If this path starts with the configure-time prefix,
|
/* If this path starts with the configure-time prefix,
|
||||||
but the compiler has been relocated, replace it
|
but the compiler has been relocated, replace it
|
||||||
with the run-time prefix. The run-time exec prefix
|
with the run-time prefix. The run-time exec prefix
|
||||||
|
|
@ -198,22 +204,27 @@ add_standard_paths (const char *sysroot, const char *iprefix,
|
||||||
= make_relative_prefix (dummy,
|
= make_relative_prefix (dummy,
|
||||||
cpp_EXEC_PREFIX,
|
cpp_EXEC_PREFIX,
|
||||||
cpp_PREFIX);
|
cpp_PREFIX);
|
||||||
|
free (dummy);
|
||||||
}
|
}
|
||||||
str = concat (relocated_prefix,
|
ostr = concat (relocated_prefix,
|
||||||
p->fname + cpp_PREFIX_len,
|
p->fname + cpp_PREFIX_len,
|
||||||
NULL);
|
NULL);
|
||||||
str = update_path (str, p->component);
|
str = update_path (ostr, p->component);
|
||||||
|
free (ostr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
str = update_path (p->fname, p->component);
|
str = update_path (p->fname, p->component);
|
||||||
|
|
||||||
if (p->multilib == 1 && imultilib)
|
if (p->multilib == 1 && imultilib)
|
||||||
str = concat (str, dir_separator_str, imultilib, NULL);
|
str = reconcat (str, str, dir_separator_str, imultilib, NULL);
|
||||||
else if (p->multilib == 2)
|
else if (p->multilib == 2)
|
||||||
{
|
{
|
||||||
if (!imultiarch)
|
if (!imultiarch)
|
||||||
continue;
|
{
|
||||||
str = concat (str, dir_separator_str, imultiarch, NULL);
|
free (str);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
str = reconcat (str, str, dir_separator_str, imultiarch, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_path (str, SYSTEM, p->cxx_aware, false);
|
add_path (str, SYSTEM, p->cxx_aware, false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue