summaryrefslogtreecommitdiff
path: root/src/fns.c
diff options
context:
space:
mode:
authorGerd Moellmann <gerd@gnu.org>2000-08-07 12:04:06 +0000
committerGerd Moellmann <gerd@gnu.org>2000-08-07 12:04:06 +0000
commitac0e96eefcdea2d4e61af557d629ff46db8da990 (patch)
tree34e03c45e51dd78cf1719214c3542c3a9a09b843 /src/fns.c
parentff3d95733df693020bbbaa4d5acfc99cd4d4c08b (diff)
downloademacs-ac0e96eefcdea2d4e61af557d629ff46db8da990.tar.gz
(sweep_weak_hash_tables): Fix the code taking unmarked
tables out of the list of all weak hash tables.
Diffstat (limited to 'src/fns.c')
-rw-r--r--src/fns.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/fns.c b/src/fns.c
index 51169efca73..1bd21d7783a 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4380,8 +4380,8 @@ sweep_weak_table (h, remove_entries_p)
void
sweep_weak_hash_tables ()
{
- Lisp_Object table;
- struct Lisp_Hash_Table *h, *prev;
+ Lisp_Object table, used, next;
+ struct Lisp_Hash_Table *h;
int marked;
/* Mark all keys and values that are in use. Keep on marking until
@@ -4403,27 +4403,24 @@ sweep_weak_hash_tables ()
while (marked);
/* Remove tables and entries that aren't used. */
- prev = NULL;
- for (table = Vweak_hash_tables; !GC_NILP (table); table = h->next_weak)
+ for (table = Vweak_hash_tables, used = Qnil; !GC_NILP (table); table = next)
{
- prev = h;
h = XHASH_TABLE (table);
-
+ next = h->next_weak;
+
if (h->size & ARRAY_MARK_FLAG)
{
+ /* TABLE is marked as used. Sweep its contents. */
if (XFASTINT (h->count) > 0)
sweep_weak_table (h, 1);
- }
- else
- {
- /* Table is not marked, and will thus be freed.
- Take it out of the list of weak hash tables. */
- if (prev)
- prev->next_weak = h->next_weak;
- else
- Vweak_hash_tables = h->next_weak;
+
+ /* Add table to the list of used weak hash tables. */
+ h->next_weak = used;
+ used = table;
}
}
+
+ Vweak_hash_tables = used;
}