aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppinit.c
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2001-08-11 12:37:19 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-08-11 12:37:19 +0000
commitbef985f3f69e6f63b144e936b599517e2d6b0601 (patch)
treefcbebbbfda56236b89a255fb6864d9fcde8b6022 /gcc/cppinit.c
parent4d5f3fbd61ad7e6a13424fa720bda3888d6ef429 (diff)
downloadgcc-bef985f3f69e6f63b144e936b599517e2d6b0601.zip
gcc-bef985f3f69e6f63b144e936b599517e2d6b0601.tar.gz
gcc-bef985f3f69e6f63b144e936b599517e2d6b0601.tar.bz2
cpphash.c (_cpp_destroy_hashtable): Use ht_destroy.
* cpphash.c (_cpp_destroy_hashtable): Use ht_destroy. * cpphash.h (CPP_IN_SYSTEM_HEADER): Fix. (struct cpp_pool): New member first. * cppinit.c (append_include_chain): Plug memory leaks. * cpplib.c (cpp_register_pragma, cpp_register_pragma_space): Allocate pragma structures from the (aligned) macro pool to avoid leaking memory. * cpplex.c (_cpp_init_pool, _cpp_free_pool): Use pool->first so we don't leak memory. * hashtable.c (ht_destroy): New. * hashtable.h (ht_destroy): New. From-SVN: r44794
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r--gcc/cppinit.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index 5a38734..63bcfdd 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -197,8 +197,8 @@ path_include (pfile, list, path)
while (1);
}
-/* Append DIR to include path PATH. DIR must be permanently allocated
- and writable. */
+/* Append DIR to include path PATH. DIR must be allocated on the
+ heap; this routine takes responsibility for freeing it. */
static void
append_include_chain (pfile, dir, path, cxx_aware)
cpp_reader *pfile;
@@ -212,8 +212,12 @@ append_include_chain (pfile, dir, path, cxx_aware)
unsigned int len;
if (*dir == '\0')
- dir = xstrdup (".");
+ {
+ free (dir);
+ dir = xstrdup (".");
+ }
_cpp_simplify_pathname (dir);
+
if (stat (dir, &st))
{
/* Dirs that don't exist are silently ignored. */
@@ -221,12 +225,14 @@ append_include_chain (pfile, dir, path, cxx_aware)
cpp_notice_from_errno (pfile, dir);
else if (CPP_OPTION (pfile, verbose))
fprintf (stderr, _("ignoring nonexistent directory \"%s\"\n"), dir);
+ free (dir);
return;
}
if (!S_ISDIR (st.st_mode))
{
cpp_notice (pfile, "%s: Not a directory", dir);
+ free (dir);
return;
}
@@ -375,7 +381,7 @@ merge_include_chains (pfile)
brack = remove_dup_dir (pfile, qtail);
}
else
- quote = brack;
+ quote = brack;
CPP_OPTION (pfile, quote_include) = quote;
CPP_OPTION (pfile, bracket_include) = brack;