changeset 3558:f7f187debe2d

(x_caught_error_message): Change type to char* from char*[]. (X_CAUGHT_ERROR_MESSAGE_SIZE): New macro. (x_error_catcher): Corresponding changes. (x_catch_errors): Corresponding changes. (x_check_errors): Do not free x_caught_error_message. (x_uncatch_errors): Set x_caught_error_message to 0 after freeing it.
author Richard M. Stallman <rms@gnu.org>
date Mon, 07 Jun 1993 23:52:45 +0000
parents 009b22e07a63
children a9b886b3f976
files src/xterm.c
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/xterm.c	Mon Jun 07 23:40:04 1993 +0000
+++ b/src/xterm.c	Mon Jun 07 23:52:45 1993 +0000
@@ -3801,7 +3801,8 @@
 }
 
 /* A buffer for storing X error messages.  */
-static char (*x_caught_error_message)[200];
+static char *x_caught_error_message;
+#define X_CAUGHT_ERROR_MESSAGE_SIZE 200
 
 /* An X error handler which stores the error message in
    x_caught_error_message.  This is what's installed when
@@ -3812,7 +3813,7 @@
      XErrorEvent *error;
 {
   XGetErrorText (display, error->error_code,
-		 *x_caught_error_message, sizeof (*x_caught_error_message));
+		 x_caught_error_message, X_CAUGHT_ERROR_MESSAGE_SIZE);
 }
 
 
@@ -3836,8 +3837,8 @@
 
   /* Set up the error buffer.  */
   x_caught_error_message
-    = (char (*)[200]) xmalloc (sizeof (*x_caught_error_message));
-  (*x_caught_error_message)[0] = '\0';
+    = (char*) xmalloc (X_CAUGHT_ERROR_MESSAGE_SIZE);
+  x_caught_error_message[0] = '\0';
 
   /* Install our little error handler.  */
   XHandleError (x_error_catcher);
@@ -3853,13 +3854,11 @@
   /* Make sure to catch any errors incurred so far.  */
   XSync (x_current_display, False);
 
-  if ((*x_caught_error_message)[0])
+  if (x_caught_error_message[0])
     {
-      char buf[256];
-
-      sprintf (buf, format, *x_caught_error_message);
-      xfree (x_caught_error_message);
-
+      char buf[X_CAUGHT_ERROR_MESSAGE_SIZE + 56];
+
+      sprintf (buf, format, x_caught_error_message);
       x_uncatch_errors ();
       error (buf);
     }
@@ -3869,6 +3868,7 @@
 x_uncatch_errors ()
 {
   xfree (x_caught_error_message);
+  x_caught_error_message = 0;
   XHandleError (x_error_quitter);
 }