emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mark_object and hash tables fail to mark all objects?


From: Simon Josefsson
Subject: mark_object and hash tables fail to mark all objects?
Date: Sun, 27 Jan 2002 12:58:58 +0100
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2.50 (i686-pc-linux-gnu)

When changing mark_object() for Lisp_Process, it occured to me that
maybe hash tables should be handled the same way as struct window,
because right now it explicitly marks its members, thereby missing to
mark count, key_and_value, next_free, next_weak.  Or was there some
deeper logic in not marking those variables?  Maybe that should be
stated in a comment.  I haven't tested the patch.

2002-01-27  Simon Josefsson  <address@hidden>

        * alloc.c (mark_object): Use a for loop instead of explicitly
        marking members of Lisp_Hash_Table, to fix lack of marking
        count, key_and_value, next_free, next_weak.

--- alloc.c.~1.259.~    Wed Jan  9 18:04:45 2002
+++ alloc.c     Sun Jan 27 12:48:08 2002
@@ -4632,8 +4632,10 @@
        }
       else if (GC_HASH_TABLE_P (obj))
        {
+         register struct Lisp_Vector *ptr = XVECTOR (obj);
          struct Lisp_Hash_Table *h = XHASH_TABLE (obj);
          EMACS_INT size = h->size;
+         register int i;
          
          /* Stop if already marked.  */
          if (size & ARRAY_MARK_FLAG)
@@ -4643,16 +4645,12 @@
          CHECK_LIVE (live_vector_p);
          h->size |= ARRAY_MARK_FLAG;
 
-         /* Mark contents.  */
-         mark_object (&h->test);
-         mark_object (&h->weak);
-         mark_object (&h->rehash_size);
-         mark_object (&h->rehash_threshold);
-         mark_object (&h->hash);
-         mark_object (&h->next);
-         mark_object (&h->index);
-         mark_object (&h->user_hash_function);
-         mark_object (&h->user_cmp_function);
+         /* There is no Lisp data below the member CMPFN in
+            struct HASH_TABLE.  Stop marking when that slot is reached.  */
+         for (i = 0;
+              (char *) &ptr->contents[i] < (char *) &h->cmpfn;
+              i++)
+           mark_object (&ptr->contents[i]);
 
          /* If hash table is not weak, mark all keys and values.
             For weak tables, mark only the vector.  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]