changeset 84693:7ee574475f20

(enum mem_type): New member for `terminal' objects. (allocate_terminal): New function. (mark_maybe_pointer, valid_lisp_object_p, mark_object): Handle terminals. (mark_terminal): New fun. (mark_terminals): Move from terminal.c.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 20 Sep 2007 21:28:51 +0000
parents 0d8dd9a91520
children 95e3b5b2f3ef
files src/alloc.c
diffstat 1 files changed, 49 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/alloc.c	Thu Sep 20 21:27:01 2007 +0000
+++ b/src/alloc.c	Thu Sep 20 21:28:51 2007 +0000
@@ -55,6 +55,7 @@
 #include "blockinput.h"
 #include "charset.h"
 #include "syssignal.h"
+#include "termhooks.h"		/* For struct terminal.  */
 #include <setjmp.h>
 
 /* GC_MALLOC_CHECK defined means perform validity checks of malloc'd
@@ -341,7 +342,8 @@
 EMACS_INT gcs_done;		/* accumulated GCs  */
 
 static void mark_buffer P_ ((Lisp_Object));
-extern void mark_terminals P_ ((void));
+static void mark_terminal P_((struct terminal *t));
+static void mark_terminals P_ ((void));
 extern void mark_kboards P_ ((void));
 extern void mark_ttys P_ ((void));
 extern void mark_backtrace P_ ((void));
@@ -382,6 +384,7 @@
   MEM_TYPE_PROCESS,
   MEM_TYPE_HASH_TABLE,
   MEM_TYPE_FRAME,
+  MEM_TYPE_TERMINAL,
   MEM_TYPE_WINDOW
 };
 
@@ -3017,6 +3020,22 @@
 }
 
 
+struct terminal *
+allocate_terminal ()
+{
+  EMACS_INT len = VECSIZE (struct terminal);
+  struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_TERMINAL);
+  EMACS_INT i;
+  Lisp_Object tmp, zero = make_number (0);
+
+  for (i = 0; i < len; ++i)
+    v->contents[i] = zero;
+  v->size = len;
+  XSETTERMINAL (tmp, v);	/* Add the appropriate tag.  */
+
+  return (struct terminal *) v;
+}
+
 struct frame *
 allocate_frame ()
 {
@@ -4320,6 +4339,7 @@
 	case MEM_TYPE_PROCESS:
 	case MEM_TYPE_HASH_TABLE:
 	case MEM_TYPE_FRAME:
+	case MEM_TYPE_TERMINAL:
 	case MEM_TYPE_WINDOW:
 	  if (live_vector_p (m, p))
 	    {
@@ -4724,6 +4744,7 @@
     case MEM_TYPE_PROCESS:
     case MEM_TYPE_HASH_TABLE:
     case MEM_TYPE_FRAME:
+    case MEM_TYPE_TERMINAL:
     case MEM_TYPE_WINDOW:
       return live_vector_p (m, p);
 
@@ -5662,6 +5683,11 @@
 	      mark_glyph_matrix (w->desired_matrix);
 	    }
 	}
+      else if (GC_TERMINALP (obj))
+	{
+	  CHECK_LIVE (live_vector_p);
+	  mark_terminal (XTERMINAL (obj));
+	}
       else if (GC_HASH_TABLE_P (obj))
 	{
 	  struct Lisp_Hash_Table *h = XHASH_TABLE (obj);
@@ -5905,6 +5931,28 @@
     }
 }
 
+/* Mark the Lisp pointers in the terminal objects.
+   Called by the Fgarbage_collector.  */
+
+static void
+mark_terminal (struct terminal *t)
+{
+  VECTOR_MARK (t);
+  mark_object (t->param_alist);
+}
+
+static void
+mark_terminals (void)
+{
+  struct terminal *t;
+  for (t = terminal_list; t; t = t->next_terminal)
+    {
+      eassert (t->name != NULL);
+      mark_terminal (t);
+    }
+}
+
+
 
 /* Value is non-zero if OBJ will survive the current GC because it's
    either marked or does not need to be marked to survive.  */