diff src/alloc.c @ 3024:b7f26b2f78bd

[xemacs-hg @ 2005-10-25 08:32:40 by ben] more mc-alloc-related factoring; make it hard to do the wrong thing postgresql/postgresql.c, postgresql/postgresql.h: MC-Alloc refactoring. ldap/eldap.c, ldap/eldap.h: MC-Alloc refactoring. alloc.c, buffer.c, console.c, emacs.c, file-coding.c, lrecord.h, lstream.c, mule-charset.c, print.c, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, symbols.c, symeval.h, unicode.c, window.c, xemacs.def.in.in: rename `struct lcrecord_header' to `struct old_lcrecord_header'; likewise for `old_basic_alloc_lcrecord', `old_free_lcrecord', `old_zero_lcrecord', `old_zero_sized_lcrecord', `old_copy_lcrecord', `old_copy_sized_lcrecord', `old_alloc_lcrecord_type'. Created new LISPOBJ_STORAGE_SIZE() used only on objects created through allocation of Lisp-Object memory instead of basic xmalloc()/xfree(). This is distinguished from malloced_storage_size(), for non-Lisp-Objects. The definition of LISPOBJ_STORAGE_SIZE() can reduce down to malloced_storage_size() when not MC-ALLOC, but with MC-ALLOC it's a different function. The whole point other than cleaning up the use of LISPOBJ_STORAGE_SIZE is to make it harder to accidentally use the old kind (lowercase) of function in new code, since you get a compile error.
author ben
date Tue, 25 Oct 2005 08:32:50 +0000
parents 1e7cc382eb16
children d30cd499e445
line wrap: on
line diff
--- a/src/alloc.c	Tue Oct 25 07:30:42 2005 +0000
+++ b/src/alloc.c	Tue Oct 25 08:32:50 2005 +0000
@@ -587,7 +587,7 @@
 /* lcrecords are chained together through their "next" field.
    After doing the mark phase, GC will walk this linked list
    and free any lcrecord which hasn't been marked. */
-static struct lcrecord_header *all_lcrecords;
+static struct old_lcrecord_header *all_lcrecords;
 #endif /* not MC_ALLOC */
 
 #ifdef MC_ALLOC
@@ -653,10 +653,10 @@
    specified size.  See lrecord.h. */
 
 void *
-basic_alloc_lcrecord (Bytecount size,
-		      const struct lrecord_implementation *implementation)
-{
-  struct lcrecord_header *lcheader;
+old_basic_alloc_lcrecord (Bytecount size,
+			  const struct lrecord_implementation *implementation)
+{
+  struct old_lcrecord_header *lcheader;
 
   type_checking_assert
     ((implementation->static_size == 0 ?
@@ -667,7 +667,7 @@
      &&
      (! (implementation->hash == NULL && implementation->equal != NULL)));
 
-  lcheader = (struct lcrecord_header *) allocate_lisp_storage (size);
+  lcheader = (struct old_lcrecord_header *) allocate_lisp_storage (size);
   set_lheader_implementation (&lcheader->lheader, implementation);
   lcheader->next = all_lcrecords;
 #if 1                           /* mly prefers to see small ID numbers */
@@ -689,7 +689,7 @@
  * Otherwise, just let the GC do its job -- that's what it's there for
  */
 void
-very_old_free_lcrecord (struct lcrecord_header *lcrecord)
+very_old_free_lcrecord (struct old_lcrecord_header *lcrecord)
 {
   if (all_lcrecords == lcrecord)
     {
@@ -697,10 +697,10 @@
     }
   else
     {
-      struct lrecord_header *header = all_lcrecords;
+      struct old_lcrecord_header *header = all_lcrecords;
       for (;;)
 	{
-	  struct lrecord_header *next = header->next;
+	  struct old_lcrecord_header *next = header->next;
 	  if (next == lcrecord)
 	    {
 	      header->next = lrecord->next;
@@ -727,7 +727,7 @@
 #ifdef MC_ALLOC
   mc_finalize_for_disksave ();
 #else /* not MC_ALLOC */
-  struct lcrecord_header *header;
+  struct old_lcrecord_header *header;
 
   for (header = all_lcrecords; header; header = header->next)
     {
@@ -760,9 +760,11 @@
 	    (char *) XRECORD_LHEADER (src) + sizeof (struct lrecord_header),
 	    size - sizeof (struct lrecord_header));
   else
-    memcpy ((char *) XRECORD_LHEADER (dst) + sizeof (struct lcrecord_header),
-	    (char *) XRECORD_LHEADER (src) + sizeof (struct lcrecord_header),
-	    size - sizeof (struct lcrecord_header));
+    memcpy ((char *) XRECORD_LHEADER (dst) +
+	    sizeof (struct old_lcrecord_header),
+	    (char *) XRECORD_LHEADER (src) +
+	    sizeof (struct old_lcrecord_header),
+	    size - sizeof (struct old_lcrecord_header));
 #endif /* not MC_ALLOC */
 }
 
@@ -2887,7 +2889,7 @@
 /************************************************************************/
 
 /* Lcrecord lists are used to manage the allocation of particular
-   sorts of lcrecords, to avoid calling basic_alloc_lcrecord() (and thus
+   sorts of lcrecords, to avoid calling BASIC_ALLOC_LCRECORD() (and thus
    malloc() and garbage-collection junk) as much as possible.
    It is similar to the Blocktype class.
 
@@ -2959,11 +2961,11 @@
 make_lcrecord_list (Elemcount size,
 		    const struct lrecord_implementation *implementation)
 {
-  /* Don't use alloc_lcrecord_type() avoid infinite recursion
+  /* Don't use old_alloc_lcrecord_type() avoid infinite recursion
      allocating this, */
   struct lcrecord_list *p = (struct lcrecord_list *)
-    basic_alloc_lcrecord (sizeof (struct lcrecord_list),
-			  &lrecord_lcrecord_list);
+    old_basic_alloc_lcrecord (sizeof (struct lcrecord_list),
+			      &lrecord_lcrecord_list);
 
   p->implementation = implementation;
   p->size = size;
@@ -3005,12 +3007,12 @@
       free_header->lcheader.free = 0;
       /* Put back the correct type, as we set it to lrecord_type_free. */
       lheader->type = list->implementation->lrecord_type_index;
-      zero_sized_lcrecord (free_header, list->size);
+      old_zero_sized_lcrecord (free_header, list->size);
       return val;
     }
   else
-    return wrap_pointer_1 (basic_alloc_lcrecord (list->size,
-						 list->implementation));
+    return wrap_pointer_1 (old_basic_alloc_lcrecord (list->size,
+						     list->implementation));
 }
 
 /* "Free" a Lisp object LCRECORD by placing it on its associated free list
@@ -3081,7 +3083,7 @@
 }
 
 void
-free_lcrecord (Lisp_Object rec)
+old_free_lcrecord (Lisp_Object rec)
 {
   int type = XRECORD_LHEADER (rec)->type;
 
@@ -3617,7 +3619,7 @@
 #define GC_CHECK_NOT_FREE(lheader)					\
       gc_checking_assert (! LRECORD_FREE_P (lheader));			\
       gc_checking_assert (LHEADER_IMPLEMENTATION (lheader)->basic_p ||	\
-			  ! ((struct lcrecord_header *) lheader)->free)
+			  ! ((struct old_lcrecord_header *) lheader)->free)
 #endif /* MC_ALLOC */
 
 #ifdef USE_KKCC
@@ -4148,7 +4150,7 @@
 {
   int type_index = h->type;
 
-  if (((struct lcrecord_header *) h)->free)
+  if (((struct old_lcrecord_header *) h)->free)
     {
       gc_checking_assert (!free_p);
       lcrecord_stats[type_index].instances_on_free_list++;
@@ -4175,9 +4177,9 @@
 #ifndef MC_ALLOC
 /* Free all unmarked records */
 static void
-sweep_lcrecords_1 (struct lcrecord_header **prev, int *used)
-{
-  struct lcrecord_header *header;
+sweep_lcrecords_1 (struct old_lcrecord_header **prev, int *used)
+{
+  struct old_lcrecord_header *header;
   int num_used = 0;
   /* int total_size = 0; */
 
@@ -4222,11 +4224,11 @@
 	}
       else
 	{
-	  struct lcrecord_header *next = header->next;
+	  struct old_lcrecord_header *next = header->next;
           *prev = next;
 	  tick_lcrecord_stats (h, 1);
 	  /* used to call finalizer right here. */
-	  xfree (header, struct lcrecord_header *);
+	  xfree (header, struct old_lcrecord_header *);
 	  header = next;
 	}
     }