This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix libiberty/hashtab.c
- From: Josef Zlomek <zlomj9am at artax dot karlin dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 30 Oct 2003 15:50:46 +0100
- Subject: [patch] Fix libiberty/hashtab.c
Hello,
the attached patch fixes a bug in hashtab.c:
When inserting n_elements is always incremented, even if inserting to
previously deleted slot. In this case, it is correct to decrease
n_deleted.
Bootstrapped/regtested x86-64.
Josef
2003-10-30 Josef Zlomek <zlomekj@suse.cz>
* hashtab.c (htab_find_slot_with_hash): Decrease n_deleted
instead of increasing n_elements when inserting to deleted slot.
Index: hashtab.c
===================================================================
RCS file: /cvs/gcc-cvs/gcc/libiberty/hashtab.c,v
retrieving revision 1.37
diff -c -3 -p -r1.37 hashtab.c
*** hashtab.c 19 Jun 2003 19:04:03 -0000 1.37
--- hashtab.c 26 Oct 2003 10:25:47 -0000
*************** htab_find_slot_with_hash (htab, element,
*** 535,548 ****
if (insert == NO_INSERT)
return NULL;
- htab->n_elements++;
-
if (first_deleted_slot)
{
*first_deleted_slot = EMPTY_ENTRY;
return first_deleted_slot;
}
return &htab->entries[index];
}
--- 535,548 ----
if (insert == NO_INSERT)
return NULL;
if (first_deleted_slot)
{
+ htab->n_deleted--;
*first_deleted_slot = EMPTY_ENTRY;
return first_deleted_slot;
}
+ htab->n_elements++;
return &htab->entries[index];
}