Make X_ERROR_MESSAGE_SIZE dependency more explicit

This avoids an alloca in x_set_mouse_color.
* src/xfns.c (x_set_mouse_color): Use local array rather than
alloca, since the string is small.
* src/xterm.c (X_ERROR_MESSAGE_SIZE): Move defn from here ...
* src/xterm.h: ... to here, and make it an enum not a macro.
This commit is contained in:
Paul Eggert 2026-05-19 10:21:56 -07:00
parent 2dbfed0532
commit a8b9fad897
3 changed files with 5 additions and 6 deletions

View file

@ -1398,10 +1398,9 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
if (x_had_errors_p (dpy))
{
const char *bad_cursor_name = NULL;
/* Bounded by X_ERROR_MESSAGE_SIZE in xterm.c. */
size_t message_length = strlen (cursor_data.error_string);
char *xmessage = alloca (1 + message_length);
memcpy (xmessage, cursor_data.error_string, message_length);
char xmessage[X_ERROR_MESSAGE_SIZE];
eassert (strlen (cursor_data.error_string) < sizeof xmessage);
strcpy (xmessage, cursor_data.error_string);
x_uncatch_errors_after_check ();

View file

@ -26321,8 +26321,6 @@ x_unwind_errors_to (int depth)
x_uncatch_errors ();
}
#define X_ERROR_MESSAGE_SIZE 200
/* An X error handler which stores the error message in the first
applicable handler in the x_error_message stack. This is called
from *x_error_handler if an x_catch_errors for DISPLAY is in

View file

@ -129,6 +129,8 @@ typedef GtkWidget *xt_or_gtk_widget;
#include "dispextern.h"
#include "termhooks.h"
enum { X_ERROR_MESSAGE_SIZE = 200 };
INLINE_HEADER_BEGIN
/* Black and white pixel values for the screen which frame F is on. */