Commit 07f08799 by Tom Tromey Committed by Tom Tromey

re PR java/24120 (jc1 incorrectly uses libiberty hashes)

	PR java/24120:
	* jcf-io.c (memoized_dirlist_hash): New function.
	(caching_stat): Use it.

From-SVN: r104809
parent edbcf8fd
2005-09-29 Tom Tromey <tromey@redhat.com>
PR java/24120:
* jcf-io.c (memoized_dirlist_hash): New function.
(caching_stat): Use it.
2005-09-21 Ranjit Mathew <rmathew@gcc.gnu.org> 2005-09-21 Ranjit Mathew <rmathew@gcc.gnu.org>
PR java/21418 PR java/21418
......
...@@ -311,6 +311,14 @@ typedef struct memoized_dirlist_entry ...@@ -311,6 +311,14 @@ typedef struct memoized_dirlist_entry
struct dirent **files; struct dirent **files;
} memoized_dirlist_entry; } memoized_dirlist_entry;
/* A hash function for a memoized_dirlist_entry. */
static hashval_t
memoized_dirlist_hash (const void *entry)
{
const memoized_dirlist_entry *mde = (const memoized_dirlist_entry *) entry;
return htab_hash_string (mde->dir);
}
/* Returns true if ENTRY (a memoized_dirlist_entry *) corresponds to /* Returns true if ENTRY (a memoized_dirlist_entry *) corresponds to
the directory given by KEY (a char *) giving the directory the directory given by KEY (a char *) giving the directory
name. */ name. */
...@@ -341,11 +349,12 @@ caching_stat (char *filename, struct stat *buf) ...@@ -341,11 +349,12 @@ caching_stat (char *filename, struct stat *buf)
char *base; char *base;
memoized_dirlist_entry *dent; memoized_dirlist_entry *dent;
void **slot; void **slot;
struct memoized_dirlist_entry temp;
/* If the hashtable has not already been created, create it now. */ /* If the hashtable has not already been created, create it now. */
if (!memoized_dirlists) if (!memoized_dirlists)
memoized_dirlists = htab_create (37, memoized_dirlists = htab_create (37,
htab_hash_string, memoized_dirlist_hash,
memoized_dirlist_lookup_eq, memoized_dirlist_lookup_eq,
NULL); NULL);
...@@ -364,8 +373,13 @@ caching_stat (char *filename, struct stat *buf) ...@@ -364,8 +373,13 @@ caching_stat (char *filename, struct stat *buf)
else else
base = filename; base = filename;
/* Obtain the entry for this directory from the hash table. */ /* Obtain the entry for this directory from the hash table. This
slot = htab_find_slot (memoized_dirlists, filename, INSERT); approach is ok since we know that the hash function only looks at
the directory name. */
temp.dir = filename;
temp.num_files = 0;
temp.files = NULL;
slot = htab_find_slot (memoized_dirlists, &temp, INSERT);
if (!*slot) if (!*slot)
{ {
/* We have not already scanned this directory; scan it now. */ /* We have not already scanned this directory; scan it now. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment