changeset 5884:d02095ea13a5

(Fmessage): Copy the text to be displayed into a malloc'd buffer.
author Karl Heuer <kwzh@gnu.org>
date Thu, 10 Feb 1994 20:50:54 +0000
parents 13cb3226cb41
children b649c51e3f6b
files src/editfns.c
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/editfns.c	Thu Feb 10 20:44:20 1994 +0000
+++ b/src/editfns.c	Thu Feb 10 20:50:54 1994 +0000
@@ -1366,6 +1366,12 @@
   return unbind_to (count, val);
 }
 
+/* Buffer for the most recent text displayed by Fmessage.  */
+static char *message_text;
+
+/* Allocated length of that buffer.  */
+static int message_length;
+
 DEFUN ("message", Fmessage, Smessage, 1, MANY, 0,
   "Print a one-line message at the bottom of the screen.\n\
 The first argument is a control string.\n\
@@ -1389,7 +1395,19 @@
     {
       register Lisp_Object val;
       val = Fformat (nargs, args);
-      message2 (XSTRING (val)->data, XSTRING (val)->size);
+      /* Copy the data so that it won't move when we GC.  */
+      if (! message_text)
+	{
+	  message_text = (char *)xmalloc (80);
+	  message_length = 80;
+	}
+      if (XSTRING (val)->size > message_length)
+	{
+	  message_length = XSTRING (val)->size;
+	  message_text = (char *)xrealloc (message_text, message_length);
+	}
+      bcopy (XSTRING (val)->data, message_text, XSTRING (val)->size);
+      message2 (message_text, XSTRING (val)->size);
       return val;
     }
 }