public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Patch: FYI: Fix PR java/24120
@ 2005-09-30  0:32 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2005-09-30  0:32 UTC (permalink / raw)
  To: Gcc Patch List; +Cc: Java Patch List

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.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-09-30  0:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-30  0:32 Patch: FYI: Fix PR java/24120 Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).