diff src/alloc.c @ 83507:81f2d90dee68

Merged from Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-188 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-189 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-190 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-191 Undo incorrect merge of etc/images/README from Gnus 5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-192 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-193 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-194 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-195 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-196 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-197 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-198 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-199 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-200 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-201 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-202 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-203 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-204 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-205 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-206 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-73 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-74 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-75 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-76 Update from CVS: README: Addition from 5.10.6 tar ball. * emacs@sv.gnu.org/gnus--rel--5.10--patch-77 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-78 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-79 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-80 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-547
author Karoly Lorentey <lorentey@elte.hu>
date Mon, 10 Apr 2006 14:52:24 +0000
parents 0cdee8b991e1 272487a77b8e
children 02e39decdc84
line wrap: on
line diff
--- a/src/alloc.c	Sat Apr 01 17:16:18 2006 +0000
+++ b/src/alloc.c	Mon Apr 10 14:52:24 2006 +0000
@@ -23,6 +23,10 @@
 #include <stdio.h>
 #include <limits.h>		/* For CHAR_BIT.  */
 
+#ifdef STDC_HEADERS
+#include <stddef.h>		/* For offsetof, used by PSEUDOVECSIZE. */
+#endif
+
 #ifdef ALLOC_DEBUG
 #undef INLINE
 #endif
@@ -3005,13 +3009,17 @@
 struct Lisp_Process *
 allocate_process ()
 {
-  EMACS_INT len = VECSIZE (struct Lisp_Process);
-  struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_PROCESS);
+  /* Memory-footprint of the object in nb of Lisp_Object fields.  */
+  EMACS_INT memlen = VECSIZE (struct Lisp_Process);
+  /* Size if we only count the actual Lisp_Object fields (which need to be
+     traced by the GC).  */
+  EMACS_INT lisplen = PSEUDOVECSIZE (struct Lisp_Process, pid);
+  struct Lisp_Vector *v = allocate_vectorlike (memlen, MEM_TYPE_PROCESS);
   EMACS_INT i;
 
-  for (i = 0; i < len; ++i)
+  for (i = 0; i < lisplen; ++i)
     v->contents[i] = Qnil;
-  v->size = len;
+  v->size = lisplen;
 
   return (struct Lisp_Process *) v;
 }
@@ -5563,6 +5571,10 @@
 	  if (size & PSEUDOVECTOR_FLAG)
 	    size &= PSEUDOVECTOR_SIZE_MASK;
 
+	  /* Note that this size is not the memory-footprint size, but only
+	     the number of Lisp_Object fields that we should trace.
+	     The distinction is used e.g. by Lisp_Process which places extra
+	     non-Lisp_Object fields at the end of the structure.  */
 	  for (i = 0; i < size; i++) /* and then mark its elements */
 	    mark_object (ptr->contents[i]);
 	}