diff src/alloc.c @ 3063:d30cd499e445

[xemacs-hg @ 2005-11-13 10:48:01 by ben] further error-checking, etc. alloc.c, lrecord.h: Move around the handling of setting of lheader->uid so it's in set_lheader_implementation() -- that way, even non-MC-ALLOC builds get useful uid's in their bare lrecords. Redo related code for strings so the non-ascii count that is stored in the uid isn't hosed. events.c: Save and restore the uid around event zeroing/deadbeefing. lisp.h: Set the correct value of MAX_STRING_ASCII_BEGIN under MC_ALLOC. lisp.h: rearrange the basic code handling ints and chars. basic int stuff goes first, followed by basic char stuff, followed in turn by stuff that mixes ints and chars. this is required since some basic defn's have become inline functions. XCHAR and CHARP have additional error-checking in that they check to make sure that the value in question is not just a character but a valid character (i.e. its numeric value is valid). print.c: debug_p4 now has a useful UID in all cases and uses it; but it also prints the raw header address (previously, you just got one of them). text.h: some basic char defn's that belonged in lisp.h have been moved there. valid_ichar_p() is moved too since the inline functions need it.
author ben
date Sun, 13 Nov 2005 10:48:04 +0000
parents b7f26b2f78bd
children 141c2920ea48 3742ea8250b5
line wrap: on
line diff
--- a/src/alloc.c	Sun Nov 13 10:39:41 2005 +0000
+++ b/src/alloc.c	Sun Nov 13 10:48:04 2005 +0000
@@ -185,7 +185,7 @@
 EMACS_INT gc_generation_number[1];
 
 /* This is just for use by the printer, to allow things to print uniquely */
-static int lrecord_uid_counter;
+int lrecord_uid_counter;
 
 /* Nonzero when calling certain hooks or doing other things where
    a GC would be bad */
@@ -606,7 +606,6 @@
   lheader = (struct lrecord_header *) mc_alloc (size);
   gc_checking_assert (LRECORD_FREE_P (lheader));
   set_lheader_implementation (lheader, implementation);
-  lheader->uid = lrecord_uid_counter++;
 #ifdef ALLOC_TYPE_STATS
   inc_lrecord_stats (size, lheader);
 #endif /* ALLOC_TYPE_STATS */
@@ -628,7 +627,6 @@
   lheader = (struct lrecord_header *) mc_alloc (size);
   gc_checking_assert (LRECORD_FREE_P (lheader));
   set_lheader_implementation (lheader, implementation);
-  lheader->uid = lrecord_uid_counter++;
 #ifdef ALLOC_TYPE_STATS
   inc_lrecord_stats (size, lheader);
 #endif /* ALLOC_TYPE_STATS */
@@ -2484,6 +2482,10 @@
   set_lheader_implementation (&s->u.lheader, &lrecord_string);
 #endif /* not MC_ALLOC */
 
+  /* The above allocations set the UID field, which overlaps with the
+     ascii-length field, to some non-zero value.  We need to zero it. */
+  XSET_STRING_ASCII_BEGIN (wrap_string (s), 0);
+
   set_lispstringp_data (s, BIG_STRING_FULLSIZE_P (fullsize)
 			? allocate_big_string_chars (length + 1)
 			: allocate_string_chars_struct (wrap_string (s),
@@ -2712,16 +2714,6 @@
 	EMACS_INT i;
 	Ibyte *ptr = XSTRING_DATA (val);
 
-#ifdef MC_ALLOC
-	/* Need this for the new allocator: strings are using the uid
-	   field for ascii_begin. The uid field is set for debugging,
-	   but the string code assumes here that ascii_begin is always
-	   zero, when not touched. This assumption is not true with
-	   the new allocator, so ascii_begin has to be set to zero
-	   here. */
-	XSET_STRING_ASCII_BEGIN (val, 0);
-#endif /* not MC_ALLOC */
-
 	for (i = XINT (length); i; i--)
 	  {
 	    Ibyte *init_ptr = init_str;
@@ -2872,6 +2864,8 @@
   set_lheader_implementation (&s->u.lheader, &lrecord_string);
   SET_C_READONLY_RECORD_HEADER (&s->u.lheader);
 #endif /* not MC_ALLOC */
+  /* Don't need to XSET_STRING_ASCII_BEGIN() here because it happens in
+     init_string_ascii_begin(). */
   s->plist = Qnil;
   set_lispstringp_data (s, (Ibyte *) contents);
   set_lispstringp_length (s, length);