This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: FYI: Fix PR java/24120


I'm checking this in on the trunk and the 4.0 branch.

This fixes PR 24120.  gcj was abusing htabs.  I looked at the other
htab_create calls in gcj; all other calls are using compatible hash
and equality functions.

Tested on x86 FC4.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

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

Index: jcf-io.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-io.c,v
retrieving revision 1.57
diff -u -r1.57 jcf-io.c
--- jcf-io.c 25 Jun 2005 00:33:03 -0000 1.57
+++ jcf-io.c 29 Sep 2005 23:07:05 -0000
@@ -311,6 +311,14 @@
   struct dirent **files;
 } 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
    the directory given by KEY (a char *) giving the directory 
    name.  */
@@ -341,11 +349,12 @@
   char *base;
   memoized_dirlist_entry *dent;
   void **slot;
+  struct memoized_dirlist_entry temp;
   
   /* If the hashtable has not already been created, create it now.  */
   if (!memoized_dirlists)
     memoized_dirlists = htab_create (37,
-				     htab_hash_string,
+				     memoized_dirlist_hash,
 				     memoized_dirlist_lookup_eq,
 				     NULL);
 
@@ -364,8 +373,13 @@
   else
     base = filename;
 
-  /* Obtain the entry for this directory from the hash table.  */
-  slot = htab_find_slot (memoized_dirlists, filename, INSERT);
+  /* Obtain the entry for this directory from the hash table.  This
+     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)
     {
       /* We have not already scanned this directory; scan it now.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]