comparison src/fns.c @ 30634:d833a6450e10

(sweep_weak_hash_tables): Fix the code taking unmarked tables out of the list of all weak hash tables.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 07 Aug 2000 12:03:19 +0000
parents 4f195cb24338
children b54946f3cbbc
comparison
equal deleted inserted replaced
30633:3ea6ae5c3939 30634:d833a6450e10
4378 from Vweak_hash_tables. Called from gc_sweep. */ 4378 from Vweak_hash_tables. Called from gc_sweep. */
4379 4379
4380 void 4380 void
4381 sweep_weak_hash_tables () 4381 sweep_weak_hash_tables ()
4382 { 4382 {
4383 Lisp_Object table; 4383 Lisp_Object table, used, next;
4384 struct Lisp_Hash_Table *h, *prev; 4384 struct Lisp_Hash_Table *h;
4385 int marked; 4385 int marked;
4386 4386
4387 /* Mark all keys and values that are in use. Keep on marking until 4387 /* Mark all keys and values that are in use. Keep on marking until
4388 there is no more change. This is necessary for cases like 4388 there is no more change. This is necessary for cases like
4389 value-weak table A containing an entry X -> Y, where Y is used in a 4389 value-weak table A containing an entry X -> Y, where Y is used in a
4401 } 4401 }
4402 } 4402 }
4403 while (marked); 4403 while (marked);
4404 4404
4405 /* Remove tables and entries that aren't used. */ 4405 /* Remove tables and entries that aren't used. */
4406 prev = NULL; 4406 for (table = Vweak_hash_tables, used = Qnil; !GC_NILP (table); table = next)
4407 for (table = Vweak_hash_tables; !GC_NILP (table); table = h->next_weak) 4407 {
4408 {
4409 prev = h;
4410 h = XHASH_TABLE (table); 4408 h = XHASH_TABLE (table);
4411 4409 next = h->next_weak;
4410
4412 if (h->size & ARRAY_MARK_FLAG) 4411 if (h->size & ARRAY_MARK_FLAG)
4413 { 4412 {
4413 /* TABLE is marked as used. Sweep its contents. */
4414 if (XFASTINT (h->count) > 0) 4414 if (XFASTINT (h->count) > 0)
4415 sweep_weak_table (h, 1); 4415 sweep_weak_table (h, 1);
4416 } 4416
4417 else 4417 /* Add table to the list of used weak hash tables. */
4418 { 4418 h->next_weak = used;
4419 /* Table is not marked, and will thus be freed. 4419 used = table;
4420 Take it out of the list of weak hash tables. */ 4420 }
4421 if (prev) 4421 }
4422 prev->next_weak = h->next_weak; 4422
4423 else 4423 Vweak_hash_tables = used;
4424 Vweak_hash_tables = h->next_weak;
4425 }
4426 }
4427 } 4424 }
4428 4425
4429 4426
4430 4427
4431 /*********************************************************************** 4428 /***********************************************************************