diff src/alloc.c @ 4959:bd169a24a554

merge
author Ben Wing <ben@xemacs.org>
date Thu, 28 Jan 2010 04:27:30 -0600
parents 304aebb79cd3
children e813cf16c015
line wrap: on
line diff
--- a/src/alloc.c	Thu Jan 28 04:02:14 2010 -0600
+++ b/src/alloc.c	Thu Jan 28 04:27:30 2010 -0600
@@ -272,7 +272,7 @@
   /* Unbelievably, calling free() on 0xDEADBEEF doesn't cause an	\
      error until much later on for many system mallocs, such as		\
      the one that comes with Solaris 2.3.  FMH!! */			\
-  assert (block != (void *) 0xDEADBEEF);				\
+  assert (block != (void *) DEADBEEF_CONSTANT);				\
   MALLOC_BEGIN ();							\
 }									\
 while (0)
@@ -283,7 +283,7 @@
   /* Unbelievably, calling free() on 0xDEADBEEF doesn't cause an	\
      error until much later on for many system mallocs, such as		\
      the one that comes with Solaris 2.3.  FMH!! */			\
-  assert (block != (void *) 0xDEADBEEF);				\
+  assert (block != (void *) DEADBEEF_CONSTANT);				\
   /* You cannot free something within dumped space, because there is	\
      no longer any sort of malloc structure associated with the block.	\
      If you are tripping this, you may need to conditionalize on	\
@@ -2874,7 +2874,7 @@
 /* Take some raw memory, encoded in some external data format,
    and convert it into a Lisp string. */
 Lisp_Object
-make_ext_string (const Extbyte *contents, EMACS_INT length,
+make_extstring (const Extbyte *contents, EMACS_INT length,
 		 Lisp_Object coding_system)
 {
   Lisp_Object string;
@@ -2885,39 +2885,93 @@
 }
 
 Lisp_Object
-build_intstring (const Ibyte *str)
+build_istring (const Ibyte *str)
 {
   /* Some strlen's crash and burn if passed null. */
   return make_string (str, (str ? qxestrlen (str) : (Bytecount) 0));
 }
 
 Lisp_Object
-build_string (const CIbyte *str)
-{
-  /* Some strlen's crash and burn if passed null. */
-  return make_string ((const Ibyte *) str, (str ? strlen (str) : 0));
+build_cistring (const CIbyte *str)
+{
+  return build_istring ((const Ibyte *) str);
+}
+
+Lisp_Object
+build_ascstring (const Ascbyte *str)
+{
+  ASSERT_ASCTEXT_ASCII (str);
+  return build_istring ((const Ibyte *) str);
 }
 
 Lisp_Object
-build_ext_string (const Extbyte *str, Lisp_Object coding_system)
+build_extstring (const Extbyte *str, Lisp_Object coding_system)
 {
   /* Some strlen's crash and burn if passed null. */
-  return make_ext_string ((const Extbyte *) str,
+  return make_extstring ((const Extbyte *) str,
 			  (str ? dfc_external_data_len (str, coding_system) :
 			   0),
 			  coding_system);
 }
 
+/* Build a string whose content is a translatable message, and translate
+   the message according to the current language environment. */
+
+Lisp_Object
+build_msg_istring (const Ibyte *str)
+{
+  return build_istring (IGETTEXT (str));
+}
+
+/* Build a string whose content is a translatable message, and translate
+   the message according to the current language environment. */
+
+Lisp_Object
+build_msg_cistring (const CIbyte *str)
+{
+  return build_msg_istring ((const Ibyte *) str);
+}
+
+/* Build a string whose content is a translatable message, and translate
+   the message according to the current language environment.
+   String must be pure-ASCII, and when compiled with error-checking,
+   an abort will have if not pure-ASCII. */
+
+Lisp_Object
+build_msg_ascstring (const Ascbyte *str)
+{
+  ASSERT_ASCTEXT_ASCII (str);
+  return build_msg_istring ((const Ibyte *) str);
+}
+
+/* Build a string whose content is a translatable message, but don't
+   translate the message immediately.  Perhaps do something else instead,
+   such as put a property on the string indicating that it needs to be
+   translated.
+
+   This is useful for strings that are built at dump time or init time,
+   rather than on-the-fly when the current language environment is set
+   properly. */
+
+Lisp_Object
+build_defer_istring (const Ibyte *str)
+{
+  Lisp_Object retval = build_istring ((Ibyte *) str);
+  /* Possibly do something to the return value */
+  return retval;
+}
+
 Lisp_Object
-build_msg_intstring (const Ibyte *str)
-{
-  return build_intstring (GETTEXT (str));
+build_defer_cistring (const CIbyte *str)
+{
+  return build_defer_istring ((Ibyte *) str);
 }
 
 Lisp_Object
-build_msg_string (const CIbyte *str)
-{
-  return build_string (CGETTEXT (str));
+build_defer_ascstring (const Ascbyte *str)
+{
+  ASSERT_ASCTEXT_ASCII (str);
+  return build_defer_istring ((Ibyte *) str);
 }
 
 Lisp_Object
@@ -3243,62 +3297,54 @@
 
 #ifdef DEBUG_XEMACS
 
-static const struct memory_description staticpro_one_name_description_1[] = {
-  { XD_ASCII_STRING, 0 },
-  { XD_END }
-};
-
-static const struct sized_memory_description staticpro_one_name_description = {
-  sizeof (char *),
-  staticpro_one_name_description_1
-};
-
-static const struct memory_description staticpro_names_description_1[] = {
-  XD_DYNARR_DESC (char_ptr_dynarr, &staticpro_one_name_description),
-  { XD_END }
-};
-
-
-extern const struct sized_memory_description staticpro_names_description;
-
-const struct sized_memory_description staticpro_names_description = {
-  sizeof (char_ptr_dynarr),
-  staticpro_names_description_1
-};
-
 /* Help debug crashes gc-marking a staticpro'ed object. */
 
 Lisp_Object_ptr_dynarr *staticpros;
-char_ptr_dynarr *staticpro_names;
+const_Ascbyte_ptr_dynarr *staticpro_names;
 
 /* Mark the Lisp_Object at non-heap VARADDRESS as a root object for
    garbage collection, and for dumping. */
 void
-staticpro_1 (Lisp_Object *varaddress, char *varname)
+staticpro_1 (Lisp_Object *varaddress, const Ascbyte *varname)
 {
   Dynarr_add (staticpros, varaddress);
   Dynarr_add (staticpro_names, varname);
   dump_add_root_lisp_object (varaddress);
 }
 
+/* External debugging function: Return the name of the variable at offset
+   COUNT. */
+const Ascbyte *
+staticpro_name (int count)
+{
+  return Dynarr_at (staticpro_names, count);
+}
 
 Lisp_Object_ptr_dynarr *staticpros_nodump;
-char_ptr_dynarr *staticpro_nodump_names;
+const_Ascbyte_ptr_dynarr *staticpro_nodump_names;
 
 /* Mark the Lisp_Object at heap VARADDRESS as a root object for
    garbage collection, but not for dumping. (See below.) */
 void
-staticpro_nodump_1 (Lisp_Object *varaddress, char *varname)
+staticpro_nodump_1 (Lisp_Object *varaddress, const Ascbyte *varname)
 {
   Dynarr_add (staticpros_nodump, varaddress);
   Dynarr_add (staticpro_nodump_names, varname);
 }
 
+/* External debugging function: Return the name of the variable at offset
+   COUNT. */
+const Ascbyte *
+staticpro_nodump_name (int count)
+{
+  return Dynarr_at (staticpro_nodump_names, count);
+}
+
 #ifdef HAVE_SHLIB
 /* Stop treating the Lisp_Object at non-heap VARADDRESS as a root object
    for garbage collection, but not for dumping. */
 void
-unstaticpro_nodump_1 (Lisp_Object *varaddress, char *varname)
+unstaticpro_nodump_1 (Lisp_Object *varaddress, const Ascbyte *varname)
 {
   Dynarr_delete_object (staticpros, varaddress);
   Dynarr_delete_object (staticpro_names, varname);
@@ -3382,42 +3428,28 @@
 
 #ifdef DEBUG_XEMACS
 
-static const struct memory_description mcpro_one_name_description_1[] = {
-  { XD_ASCII_STRING, 0 },
-  { XD_END }
-};
-
-static const struct sized_memory_description mcpro_one_name_description = {
-  sizeof (char *),
-  mcpro_one_name_description_1
-};
-
-static const struct memory_description mcpro_names_description_1[] = {
-  XD_DYNARR_DESC (char_ptr_dynarr, &mcpro_one_name_description),
-  { XD_END }
-};
-
-extern const struct sized_memory_description mcpro_names_description;
-
-const struct sized_memory_description mcpro_names_description = {
-  sizeof (char_ptr_dynarr),
-  mcpro_names_description_1
-};
-
 /* Help debug crashes gc-marking a mcpro'ed object. */
 
 Lisp_Object_dynarr *mcpros;
-char_ptr_dynarr *mcpro_names;
+const_Ascbyte_ptr_dynarr *mcpro_names;
 
 /* Mark the Lisp_Object at non-heap VARADDRESS as a root object for
    garbage collection, and for dumping. */
 void
-mcpro_1 (Lisp_Object varaddress, char *varname)
+mcpro_1 (Lisp_Object varaddress, const Ascbyte *varname)
 {
   Dynarr_add (mcpros, varaddress);
   Dynarr_add (mcpro_names, varname);
 }
 
+/* External debugging function: Return the name of the variable at offset
+   COUNT. */
+const Ascbyte *
+mcpro_name (int count)
+{
+  return Dynarr_at (mcpro_names, count);
+}
+
 #else /* not DEBUG_XEMACS */
 
 Lisp_Object_dynarr *mcpros;
@@ -4449,8 +4481,8 @@
     {
       if (lrecord_stats[i].instances_in_use != 0)
         {
-          char buf [255];
-          const char *name = lrecord_implementations_table[i]->name;
+          Ascbyte buf[255];
+          const Ascbyte *name = lrecord_implementations_table[i]->name;
 	  int len = strlen (name);
 
 	  if (lrecord_stats[i].bytes_in_use_including_overhead != 
@@ -4493,8 +4525,8 @@
           || lcrecord_stats[i].bytes_freed != 0
 	  || lcrecord_stats[i].instances_on_free_list != 0)
         {
-          char buf [255];
-          const char *name = lrecord_implementations_table[i]->name;
+          Ascbyte buf[255];
+          const Ascbyte *name = lrecord_implementations_table[i]->name;
 	  int len = strlen (name);
 
           sprintf (buf, "%s-storage", name);
@@ -4936,7 +4968,8 @@
 #ifdef DEBUG_XEMACS
   if (staticpro_nodump_names)
     Dynarr_free (staticpro_nodump_names);
-  staticpro_nodump_names = Dynarr_new2 (char_ptr_dynarr, char *);
+  staticpro_nodump_names = Dynarr_new2 (const_Ascbyte_ptr_dynarr,
+					const Ascbyte *);
   Dynarr_resize (staticpro_nodump_names, 100); /* ditto */
 #endif
 
@@ -4945,9 +4978,10 @@
   Dynarr_resize (mcpros, 1410); /* merely a small optimization */
   dump_add_root_block_ptr (&mcpros, &mcpros_description);
 #ifdef DEBUG_XEMACS
-  mcpro_names = Dynarr_new2 (char_ptr_dynarr, char *);
+  mcpro_names = Dynarr_new2 (const_Ascbyte_ptr_dynarr, const Ascbyte *);
   Dynarr_resize (mcpro_names, 1410); /* merely a small optimization */
-  dump_add_root_block_ptr (&mcpro_names, &mcpro_names_description);
+  dump_add_root_block_ptr (&mcpro_names,
+			   &const_Ascbyte_ptr_dynarr_description_1);
 #endif
 #endif /* NEW_GC */
 
@@ -5040,9 +5074,10 @@
   Dynarr_resize (staticpros, 1410); /* merely a small optimization */
   dump_add_root_block_ptr (&staticpros, &staticpros_description);
 #ifdef DEBUG_XEMACS
-  staticpro_names = Dynarr_new2 (char_ptr_dynarr, char *);
+  staticpro_names = Dynarr_new2 (const_Ascbyte_ptr_dynarr, const Ascbyte *);
   Dynarr_resize (staticpro_names, 1410); /* merely a small optimization */
-  dump_add_root_block_ptr (&staticpro_names, &staticpro_names_description);
+  dump_add_root_block_ptr (&staticpro_names,
+			   &const_Ascbyte_ptr_dynarr_description);
 #endif
 
 #ifdef NEW_GC
@@ -5050,9 +5085,10 @@
   Dynarr_resize (mcpros, 1410); /* merely a small optimization */
   dump_add_root_block_ptr (&mcpros, &mcpros_description);
 #ifdef DEBUG_XEMACS
-  mcpro_names = Dynarr_new2 (char_ptr_dynarr, char *);
+  mcpro_names = Dynarr_new2 (const_Ascbyte_ptr_dynarr, const Ascbyte *);
   Dynarr_resize (mcpro_names, 1410); /* merely a small optimization */
-  dump_add_root_block_ptr (&mcpro_names, &mcpro_names_description);
+  dump_add_root_block_ptr (&mcpro_names,
+			   &const_Ascbyte_ptr_dynarr_description);
 #endif
 #else /* not NEW_GC */
   init_lcrecord_lists ();