Commit 5bb7dfee authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* lisp.h (struct Lisp_Hash_Table): Turn next_weak into a bare pointer.

* fns.c (weak_hash_tables): Rename from Vweak_hash_tables and turned
from a Lisp_Object into a bare pointer.
(make_hash_table, copy_hash_table, sweep_weak_hash_tables, init_fns):
Adjust the code correspondingly.
parent 8991fa8f
2007-07-11 Stefan Monnier <monnier@iro.umontreal.ca>
* lisp.h (struct Lisp_Hash_Table): Turn next_weak into a bare pointer.
* fns.c (weak_hash_tables): Rename from Vweak_hash_tables and turned
from a Lisp_Object into a bare pointer.
(make_hash_table, copy_hash_table, sweep_weak_hash_tables, init_fns):
Adjust the code correspondingly.
* alloc.c (emacs_blocked_free): Remove unused var `bytes_used_now'.
* term.c: Include unistd.h for ttyname, used in handle_one_term_event.
(term_show_mouse_face): Remove unused var `j'.
(handle_one_term_event): Remove unused vars `i' and `j'.
Don't cast return value of ttyname since it's not necessary.
2007-07-10 Stefan Monnier <monnier@iro.umontreal.ca> 2007-07-10 Stefan Monnier <monnier@iro.umontreal.ca>
   
* alloc.c (mark_maybe_pointer): Enforce mult-of-8 alignment when using * alloc.c (mark_maybe_pointer): Enforce mult-of-8 alignment when using
......
...@@ -4268,7 +4268,7 @@ base64_decode_1 (from, to, length, multibyte, nchars_return) ...@@ -4268,7 +4268,7 @@ base64_decode_1 (from, to, length, multibyte, nchars_return)
/* The list of all weak hash tables. Don't staticpro this one. */ /* The list of all weak hash tables. Don't staticpro this one. */
Lisp_Object Vweak_hash_tables; struct Lisp_Hash_Table *weak_hash_tables;
/* Various symbols. */ /* Various symbols. */
...@@ -4614,11 +4614,11 @@ make_hash_table (test, size, rehash_size, rehash_threshold, weak, ...@@ -4614,11 +4614,11 @@ make_hash_table (test, size, rehash_size, rehash_threshold, weak,
/* Maybe add this hash table to the list of all weak hash tables. */ /* Maybe add this hash table to the list of all weak hash tables. */
if (NILP (h->weak)) if (NILP (h->weak))
h->next_weak = Qnil; h->next_weak = NULL;
else else
{ {
h->next_weak = Vweak_hash_tables; h->next_weak = weak_hash_tables;
Vweak_hash_tables = table; weak_hash_tables = h;
} }
return table; return table;
...@@ -4649,8 +4649,8 @@ copy_hash_table (h1) ...@@ -4649,8 +4649,8 @@ copy_hash_table (h1)
/* Maybe add this hash table to the list of all weak hash tables. */ /* Maybe add this hash table to the list of all weak hash tables. */
if (!NILP (h2->weak)) if (!NILP (h2->weak))
{ {
h2->next_weak = Vweak_hash_tables; h2->next_weak = weak_hash_tables;
Vweak_hash_tables = table; weak_hash_tables = h2;
} }
return table; return table;
...@@ -4969,13 +4969,12 @@ sweep_weak_table (h, remove_entries_p) ...@@ -4969,13 +4969,12 @@ sweep_weak_table (h, remove_entries_p)
/* Remove elements from weak hash tables that don't survive the /* Remove elements from weak hash tables that don't survive the
current garbage collection. Remove weak tables that don't survive current garbage collection. Remove weak tables that don't survive
from Vweak_hash_tables. Called from gc_sweep. */ from weak_hash_tables. Called from gc_sweep. */
void void
sweep_weak_hash_tables () sweep_weak_hash_tables ()
{ {
Lisp_Object table, used, next; struct Lisp_Hash_Table *h, *used, *next;
struct Lisp_Hash_Table *h;
int marked; int marked;
/* Mark all keys and values that are in use. Keep on marking until /* Mark all keys and values that are in use. Keep on marking until
...@@ -4987,9 +4986,8 @@ sweep_weak_hash_tables () ...@@ -4987,9 +4986,8 @@ sweep_weak_hash_tables ()
do do
{ {
marked = 0; marked = 0;
for (table = Vweak_hash_tables; !GC_NILP (table); table = h->next_weak) for (h = weak_hash_tables; h; h = h->next_weak)
{ {
h = XHASH_TABLE (table);
if (h->size & ARRAY_MARK_FLAG) if (h->size & ARRAY_MARK_FLAG)
marked |= sweep_weak_table (h, 0); marked |= sweep_weak_table (h, 0);
} }
...@@ -4997,9 +4995,8 @@ sweep_weak_hash_tables () ...@@ -4997,9 +4995,8 @@ sweep_weak_hash_tables ()
while (marked); while (marked);
/* Remove tables and entries that aren't used. */ /* Remove tables and entries that aren't used. */
for (table = Vweak_hash_tables, used = Qnil; !GC_NILP (table); table = next) for (h = weak_hash_tables, used = NULL; h; h = next)
{ {
h = XHASH_TABLE (table);
next = h->next_weak; next = h->next_weak;
if (h->size & ARRAY_MARK_FLAG) if (h->size & ARRAY_MARK_FLAG)
...@@ -5010,11 +5007,11 @@ sweep_weak_hash_tables () ...@@ -5010,11 +5007,11 @@ sweep_weak_hash_tables ()
/* Add table to the list of used weak hash tables. */ /* Add table to the list of used weak hash tables. */
h->next_weak = used; h->next_weak = used;
used = table; used = h;
} }
} }
Vweak_hash_tables = used; weak_hash_tables = used;
} }
...@@ -5915,7 +5912,7 @@ used if both `use-dialog-box' and this variable are non-nil. */); ...@@ -5915,7 +5912,7 @@ used if both `use-dialog-box' and this variable are non-nil. */);
void void
init_fns () init_fns ()
{ {
Vweak_hash_tables = Qnil; weak_hash_tables = NULL;
} }
/* arch-tag: 787f8219-5b74-46bd-8469-7e1cc475fa31 /* arch-tag: 787f8219-5b74-46bd-8469-7e1cc475fa31
......
...@@ -56,7 +56,7 @@ Boston, MA 02110-1301, USA. */ ...@@ -56,7 +56,7 @@ Boston, MA 02110-1301, USA. */
#ifdef GC_CHECK_CONS_LIST #ifdef GC_CHECK_CONS_LIST
#define CHECK_CONS_LIST() check_cons_list() #define CHECK_CONS_LIST() check_cons_list()
#else #else
#define CHECK_CONS_LIST() 0 #define CHECK_CONS_LIST() ((void)0)
#endif #endif
/* These are default choices for the types to use. */ /* These are default choices for the types to use. */
...@@ -1041,16 +1041,16 @@ struct Lisp_Hash_Table ...@@ -1041,16 +1041,16 @@ struct Lisp_Hash_Table
hash table size to reduce collisions. */ hash table size to reduce collisions. */
Lisp_Object index; Lisp_Object index;
/* Next weak hash table if this is a weak hash table. The head
of the list is in Vweak_hash_tables. */
Lisp_Object next_weak;
/* User-supplied hash function, or nil. */ /* User-supplied hash function, or nil. */
Lisp_Object user_hash_function; Lisp_Object user_hash_function;
/* User-supplied key comparison function, or nil. */ /* User-supplied key comparison function, or nil. */
Lisp_Object user_cmp_function; Lisp_Object user_cmp_function;
/* Next weak hash table if this is a weak hash table. The head
of the list is in weak_hash_tables. */
struct Lisp_Hash_Table *next_weak;
/* C function to compare two keys. */ /* C function to compare two keys. */
int (* cmpfn) P_ ((struct Lisp_Hash_Table *, Lisp_Object, int (* cmpfn) P_ ((struct Lisp_Hash_Table *, Lisp_Object,
unsigned, Lisp_Object, unsigned)); unsigned, Lisp_Object, unsigned));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment