summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-04-08 12:59:22 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-04-08 13:01:21 -0700
commita038df77de7b1aa2d73a6478493b8838b59e4982 (patch)
treefbaa0087bab52a815dfd249d189301e53de0d345
parent31e9087cdcd0b78b2247c3d8532290881abfbb08 (diff)
downloademacs-a038df77de7b1aa2d73a6478493b8838b59e4982.tar.gz
Allow gap before first non-Lisp pseudovec member
Problem reported by Keith David Bershatsky in: https://lists.gnu.org/r/emacs-devel/2019-04/msg00259.html Solution suggested by Stefan Monnier in: https://lists.gnu.org/r/emacs-devel/2019-04/msg00282.html * src/buffer.h (BUFFER_LISP_SIZE): Simplify by using PSEUDOVECSIZE. (BUFFER_REST_SIZE): Simplify by using VECSIZE and BUFFER_LISP_SIZE. * src/lisp.h (PSEUDOVECSIZE): Base it on the last Lisp field, not the first non-Lisp field. All callers changed. Callers without Lisp fields changed to use ALLOCATE_PLAIN_PSEUDOVECTOR. (ALLOCATE_PLAIN_PSEUDOVECTOR): New macro.
-rw-r--r--src/alloc.c20
-rw-r--r--src/bignum.c8
-rw-r--r--src/buffer.h14
-rw-r--r--src/emacs-module.c2
-rw-r--r--src/fns.c2
-rw-r--r--src/frame.c3
-rw-r--r--src/frame.h7
-rw-r--r--src/lisp.h24
-rw-r--r--src/pdumper.c4
-rw-r--r--src/process.c3
-rw-r--r--src/process.h4
-rw-r--r--src/termhooks.h2
-rw-r--r--src/terminal.c4
-rw-r--r--src/thread.c8
-rw-r--r--src/thread.h2
-rw-r--r--src/w32term.c2
-rw-r--r--src/window.c23
-rw-r--r--src/window.h5
-rw-r--r--src/xterm.c4
-rw-r--r--src/xterm.h2
-rw-r--r--src/xwidget.c5
-rw-r--r--src/xwidget.h6
22 files changed, 76 insertions, 78 deletions
diff --git a/src/alloc.c b/src/alloc.c
index e48807c49ad..dd783863be8 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3718,8 +3718,8 @@ Its value is void, and its function definition and property list are nil. */)
Lisp_Object
make_misc_ptr (void *a)
{
- struct Lisp_Misc_Ptr *p = ALLOCATE_PSEUDOVECTOR (struct Lisp_Misc_Ptr, pointer,
- PVEC_MISC_PTR);
+ struct Lisp_Misc_Ptr *p = ALLOCATE_PLAIN_PSEUDOVECTOR (struct Lisp_Misc_Ptr,
+ PVEC_MISC_PTR);
p->pointer = a;
return make_lisp_ptr (p, Lisp_Vectorlike);
}
@@ -3729,7 +3729,7 @@ make_misc_ptr (void *a)
Lisp_Object
build_overlay (Lisp_Object start, Lisp_Object end, Lisp_Object plist)
{
- struct Lisp_Overlay *p = ALLOCATE_PSEUDOVECTOR (struct Lisp_Overlay, next,
+ struct Lisp_Overlay *p = ALLOCATE_PSEUDOVECTOR (struct Lisp_Overlay, plist,
PVEC_OVERLAY);
Lisp_Object overlay = make_lisp_ptr (p, Lisp_Vectorlike);
OVERLAY_START (overlay) = start;
@@ -3743,8 +3743,8 @@ DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0,
doc: /* Return a newly allocated marker which does not point at any place. */)
(void)
{
- struct Lisp_Marker *p = ALLOCATE_PSEUDOVECTOR (struct Lisp_Marker, buffer,
- PVEC_MARKER);
+ struct Lisp_Marker *p = ALLOCATE_PLAIN_PSEUDOVECTOR (struct Lisp_Marker,
+ PVEC_MARKER);
p->buffer = 0;
p->bytepos = 0;
p->charpos = 0;
@@ -3766,8 +3766,8 @@ build_marker (struct buffer *buf, ptrdiff_t charpos, ptrdiff_t bytepos)
/* Every character is at least one byte. */
eassert (charpos <= bytepos);
- struct Lisp_Marker *m = ALLOCATE_PSEUDOVECTOR (struct Lisp_Marker, buffer,
- PVEC_MARKER);
+ struct Lisp_Marker *m = ALLOCATE_PLAIN_PSEUDOVECTOR (struct Lisp_Marker,
+ PVEC_MARKER);
m->buffer = buf;
m->charpos = charpos;
m->bytepos = bytepos;
@@ -3821,8 +3821,8 @@ make_event_array (ptrdiff_t nargs, Lisp_Object *args)
Lisp_Object
make_user_ptr (void (*finalizer) (void *), void *p)
{
- struct Lisp_User_Ptr *uptr = ALLOCATE_PSEUDOVECTOR (struct Lisp_User_Ptr,
- finalizer, PVEC_USER_PTR);
+ struct Lisp_User_Ptr *uptr
+ = ALLOCATE_PLAIN_PSEUDOVECTOR (struct Lisp_User_Ptr, PVEC_USER_PTR);
uptr->finalizer = finalizer;
uptr->p = p;
return make_lisp_ptr (uptr, Lisp_Vectorlike);
@@ -3945,7 +3945,7 @@ FUNCTION. FUNCTION will be run once per finalizer object. */)
(Lisp_Object function)
{
struct Lisp_Finalizer *finalizer
- = ALLOCATE_PSEUDOVECTOR (struct Lisp_Finalizer, prev, PVEC_FINALIZER);
+ = ALLOCATE_PSEUDOVECTOR (struct Lisp_Finalizer, function, PVEC_FINALIZER);
finalizer->function = function;
finalizer->prev = finalizer->next = NULL;
finalizer_insert (&finalizers, finalizer);
diff --git a/src/bignum.c b/src/bignum.c
index 4118601e108..009d73118c2 100644
--- a/src/bignum.c
+++ b/src/bignum.c
@@ -86,8 +86,8 @@ make_bignum_bits (size_t bits)
if (integer_width < bits)
overflow_error ();
- struct Lisp_Bignum *b = ALLOCATE_PSEUDOVECTOR (struct Lisp_Bignum, value,
- PVEC_BIGNUM);
+ struct Lisp_Bignum *b = ALLOCATE_PLAIN_PSEUDOVECTOR (struct Lisp_Bignum,
+ PVEC_BIGNUM);
mpz_init (b->value);
mpz_swap (b->value, mpz[0]);
return make_lisp_ptr (b, Lisp_Vectorlike);
@@ -342,8 +342,8 @@ bignum_to_string (Lisp_Object num, int base)
Lisp_Object
make_bignum_str (char const *num, int base)
{
- struct Lisp_Bignum *b = ALLOCATE_PSEUDOVECTOR (struct Lisp_Bignum, value,
- PVEC_BIGNUM);
+ struct Lisp_Bignum *b = ALLOCATE_PLAIN_PSEUDOVECTOR (struct Lisp_Bignum,
+ PVEC_BIGNUM);
mpz_init (b->value);
int check = mpz_set_str (b->value, num, base);
eassert (check == 0);
diff --git a/src/buffer.h b/src/buffer.h
index 63b162161c6..f42c3e97b97 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -741,8 +741,8 @@ struct buffer
See `cursor-type' for other values. */
Lisp_Object cursor_in_non_selected_windows_;
- /* No more Lisp_Object beyond this point. Except undo_list,
- which is handled specially in Fgarbage_collect. */
+ /* No more Lisp_Object beyond cursor_in_non_selected_windows_.
+ Except undo_list, which is handled specially in Fgarbage_collect. */
/* This structure holds the coordinates of the buffer contents
in ordinary buffers. In indirect buffers, this is not used. */
@@ -1019,14 +1019,12 @@ bset_width_table (struct buffer *b, Lisp_Object val)
structure, make sure that this is still correct. */
#define BUFFER_LISP_SIZE \
- ((offsetof (struct buffer, own_text) - header_size) / word_size)
+ PSEUDOVECSIZE (struct buffer, cursor_in_non_selected_windows_)
-/* Size of the struct buffer part beyond leading Lisp_Objects, in word_size
- units. Rounding is needed for --with-wide-int configuration. */
+/* Allocated size of the struct buffer part beyond leading
+ Lisp_Objects, in word_size units. */
-#define BUFFER_REST_SIZE \
- ((((sizeof (struct buffer) - offsetof (struct buffer, own_text)) \
- + (word_size - 1)) & ~(word_size - 1)) / word_size)
+#define BUFFER_REST_SIZE (VECSIZE (struct buffer) - BUFFER_LISP_SIZE)
/* Initialize the pseudovector header of buffer object. BUFFER_LISP_SIZE
is required for GC, but BUFFER_REST_SIZE is set up just to be consistent
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 2bb1062574e..47ca3368c0f 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -427,7 +427,7 @@ static struct Lisp_Module_Function *
allocate_module_function (void)
{
return ALLOCATE_PSEUDOVECTOR (struct Lisp_Module_Function,
- min_arity, PVEC_MODULE_FUNCTION);
+ documentation, PVEC_MODULE_FUNCTION);
}
#define XSET_MODULE_FUNCTION(var, ptr) \
diff --git a/src/fns.c b/src/fns.c
index b97b132b0fe..c3202495daf 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3904,7 +3904,7 @@ static struct Lisp_Hash_Table *
allocate_hash_table (void)
{
return ALLOCATE_PSEUDOVECTOR (struct Lisp_Hash_Table,
- count, PVEC_HASH_TABLE);
+ index, PVEC_HASH_TABLE);
}
/* An upper bound on the size of a hash table index. It must fit in
diff --git a/src/frame.c b/src/frame.c
index 6fdb7d0cbb9..192ef4244fb 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -798,7 +798,8 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
static struct frame *
allocate_frame (void)
{
- return ALLOCATE_ZEROED_PSEUDOVECTOR (struct frame, face_cache, PVEC_FRAME);
+ return ALLOCATE_ZEROED_PSEUDOVECTOR (struct frame, tool_bar_items,
+ PVEC_FRAME);
}
struct frame *
diff --git a/src/frame.h b/src/frame.h
index ed62e7ace0f..ec8f61465f2 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -190,9 +190,6 @@ struct frame
Lisp_Object current_tool_bar_string;
#endif
- /* Desired and current tool-bar items. */
- Lisp_Object tool_bar_items;
-
#ifdef USE_GTK
/* Where tool bar is, can be left, right, top or bottom.
Except with GTK, the only supported position is `top'. */
@@ -204,7 +201,9 @@ struct frame
Lisp_Object font_data;
#endif
- /* Beyond here, there should be no more Lisp_Object components. */
+ /* Desired and current tool-bar items. */
+ Lisp_Object tool_bar_items;
+ /* tool_bar_items should be the last Lisp_Object member. */
/* Cache of realized faces. */
struct face_cache *face_cache;
diff --git a/src/lisp.h b/src/lisp.h
index a0a7cbdf518..681efc3b52b 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1904,9 +1904,9 @@ memclear (void *p, ptrdiff_t nbytes)
at the end and we need to compute the number of Lisp_Object fields (the
ones that the GC needs to trace). */
-#define PSEUDOVECSIZE(type, nonlispfield) \
- (offsetof (type, nonlispfield) < header_size \
- ? 0 : (offsetof (type, nonlispfield) - header_size) / word_size)
+#define PSEUDOVECSIZE(type, lastlispfield) \
+ (offsetof (type, lastlispfield) + word_size < header_size \
+ ? 0 : (offsetof (type, lastlispfield) + word_size - header_size) / word_size)
/* Compute A OP B, using the unsigned comparison operator OP. A and B
should be integer expressions. This is not the same as
@@ -2109,11 +2109,14 @@ enum char_table_specials
/* This is the number of slots that every char table must have. This
counts the ordinary slots and the top, defalt, parent, and purpose
slots. */
- CHAR_TABLE_STANDARD_SLOTS = PSEUDOVECSIZE (struct Lisp_Char_Table, extras),
+ CHAR_TABLE_STANDARD_SLOTS
+ = (PSEUDOVECSIZE (struct Lisp_Char_Table, contents) - 1
+ + (1 << CHARTAB_SIZE_BITS_0)),
- /* This is an index of first Lisp_Object field in Lisp_Sub_Char_Table
+ /* This is the index of the first Lisp_Object field in Lisp_Sub_Char_Table
when the latter is treated as an ordinary Lisp_Vector. */
- SUB_CHAR_TABLE_OFFSET = PSEUDOVECSIZE (struct Lisp_Sub_Char_Table, contents)
+ SUB_CHAR_TABLE_OFFSET
+ = PSEUDOVECSIZE (struct Lisp_Sub_Char_Table, contents) - 1
};
/* Sanity-check pseudovector layout. */
@@ -2313,8 +2316,8 @@ struct Lisp_Hash_Table
hash table size to reduce collisions. */
Lisp_Object index;
- /* Only the fields above are traced normally by the GC. The ones below
- `count' are special and are either ignored by the GC or traced in
+ /* Only the fields above are traced normally by the GC. The ones after
+ 'index' are special and are either ignored by the GC or traced in
a special way (e.g. because of weakness). */
/* Number of key/value entries in the table. */
@@ -3940,6 +3943,11 @@ make_nil_vector (ptrdiff_t size)
extern struct Lisp_Vector *allocate_pseudovector (int, int, int,
enum pvec_type);
+/* Allocate uninitialized pseudovector with no Lisp_Object slots. */
+
+#define ALLOCATE_PLAIN_PSEUDOVECTOR(type, tag) \
+ ((type *) allocate_pseudovector (VECSIZE (type), 0, 0, tag))
+
/* Allocate partially initialized pseudovector where all Lisp_Object
slots are set to Qnil but the rest (if any) is left uninitialized. */
diff --git a/src/pdumper.c b/src/pdumper.c
index b19f206d1bd..cb2915cb203 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2702,7 +2702,7 @@ dump_hash_table (struct dump_context *ctx,
Lisp_Object object,
dump_off offset)
{
-#if CHECK_STRUCTS && !defined (HASH_Lisp_Hash_Table_73C9BFB7D1)
+#if CHECK_STRUCTS && !defined HASH_Lisp_Hash_Table_EF95ED06FF
# error "Lisp_Hash_Table changed. See CHECK_STRUCTS comment."
#endif
const struct Lisp_Hash_Table *hash_in = XHASH_TABLE (object);
@@ -2770,7 +2770,7 @@ dump_hash_table (struct dump_context *ctx,
static dump_off
dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer)
{
-#if CHECK_STRUCTS && !defined HASH_buffer_2CEE653E74
+#if CHECK_STRUCTS && !defined HASH_buffer_E34A11C6B9
# error "buffer changed. See CHECK_STRUCTS comment."
#endif
struct buffer munged_buffer = *in_buffer;
diff --git a/src/process.c b/src/process.c
index 802ac026249..6770a5ed884 100644
--- a/src/process.c
+++ b/src/process.c
@@ -858,7 +858,8 @@ allocate_pty (char pty_name[PTY_NAME_SIZE])
static struct Lisp_Process *
allocate_process (void)
{
- return ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Process, pid, PVEC_PROCESS);
+ return ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Process, thread,
+ PVEC_PROCESS);
}
static Lisp_Object
diff --git a/src/process.h b/src/process.h
index d66aa062a54..5e957c4298e 100644
--- a/src/process.h
+++ b/src/process.h
@@ -117,9 +117,7 @@ struct Lisp_Process
/* The thread a process is linked to, or nil for any thread. */
Lisp_Object thread;
-
- /* After this point, there are no Lisp_Objects any more. */
- /* alloc.c assumes that `pid' is the first such non-Lisp slot. */
+ /* After this point, there are no Lisp_Objects. */
/* Process ID. A positive value is a child process ID.
Zero is for pseudo-processes such as network or serial connections,
diff --git a/src/termhooks.h b/src/termhooks.h
index ca6782f461b..a92b981110d 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -408,7 +408,7 @@ struct terminal
whether the mapping is available. */
Lisp_Object glyph_code_table;
- /* All fields before `next_terminal' should be Lisp_Object and are traced
+ /* All earlier fields should be Lisp_Objects and are traced
by the GC. All fields afterwards are ignored by the GC. */
/* Chain of all terminal devices. */
diff --git a/src/terminal.c b/src/terminal.c
index 1d7a965dd26..0ee0121e35e 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -264,8 +264,8 @@ get_named_terminal (const char *name)
static struct terminal *
allocate_terminal (void)
{
- return ALLOCATE_ZEROED_PSEUDOVECTOR
- (struct terminal, next_terminal, PVEC_TERMINAL);
+ return ALLOCATE_ZEROED_PSEUDOVECTOR (struct terminal, glyph_code_table,
+ PVEC_TERMINAL);
}
/* Create a new terminal object of TYPE and add it to the terminal list. RIF
diff --git a/src/thread.c b/src/thread.c
index e51d6144347..670680f2b0d 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -267,7 +267,7 @@ informational only. */)
if (!NILP (name))
CHECK_STRING (name);
- mutex = ALLOCATE_PSEUDOVECTOR (struct Lisp_Mutex, mutex, PVEC_MUTEX);
+ mutex = ALLOCATE_PSEUDOVECTOR (struct Lisp_Mutex, name, PVEC_MUTEX);
memset ((char *) mutex + offsetof (struct Lisp_Mutex, mutex),
0, sizeof (struct Lisp_Mutex) - offsetof (struct Lisp_Mutex,
mutex));
@@ -386,7 +386,7 @@ informational only. */)
if (!NILP (name))
CHECK_STRING (name);
- condvar = ALLOCATE_PSEUDOVECTOR (struct Lisp_CondVar, cond, PVEC_CONDVAR);
+ condvar = ALLOCATE_PSEUDOVECTOR (struct Lisp_CondVar, name, PVEC_CONDVAR);
memset ((char *) condvar + offsetof (struct Lisp_CondVar, cond),
0, sizeof (struct Lisp_CondVar) - offsetof (struct Lisp_CondVar,
cond));
@@ -805,7 +805,7 @@ If NAME is given, it must be a string; it names the new thread. */)
if (!NILP (name))
CHECK_STRING (name);
- new_thread = ALLOCATE_PSEUDOVECTOR (struct thread_state, m_stack_bottom,
+ new_thread = ALLOCATE_PSEUDOVECTOR (struct thread_state, event_object,
PVEC_THREAD);
memset ((char *) new_thread + offset, 0,
sizeof (struct thread_state) - offset);
@@ -1064,7 +1064,7 @@ static void
init_main_thread (void)
{
main_thread.s.header.size
- = PSEUDOVECSIZE (struct thread_state, m_stack_bottom);
+ = PSEUDOVECSIZE (struct thread_state, event_object);
XSETPVECTYPE (&main_thread.s, PVEC_THREAD);
main_thread.s.m_last_thing_searched = Qnil;
main_thread.s.m_saved_last_thing_searched = Qnil;
diff --git a/src/thread.h b/src/thread.h
index 50f8f5cbe0a..0514669a87d 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -61,8 +61,8 @@ struct thread_state
/* If we are waiting for some event, this holds the object we are
waiting on. */
Lisp_Object event_object;
+ /* event_object must be the last Lisp field. */
- /* m_stack_bottom must be the first non-Lisp field. */
/* An address near the bottom of the stack.
Tells GC how to save a copy of the stack. */
char const *m_stack_bottom;
diff --git a/src/w32term.c b/src/w32term.c
index 7dbeda7a716..bb1f0bad018 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3896,7 +3896,7 @@ x_scroll_bar_create (struct window *w, int left, int top, int width, int height,
HWND hwnd;
SCROLLINFO si;
struct scroll_bar *bar
- = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, top, PVEC_OTHER);
+ = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, w32_widget_high, PVEC_OTHER);
Lisp_Object barobj;
block_input ();
diff --git a/src/window.c b/src/window.c
index be338c2af61..f911c0c7d44 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4170,8 +4170,8 @@ temp_output_buffer_show (register Lisp_Object buf)
static struct window *
allocate_window (void)
{
- return ALLOCATE_ZEROED_PSEUDOVECTOR
- (struct window, current_matrix, PVEC_WINDOW);
+ return ALLOCATE_ZEROED_PSEUDOVECTOR (struct window, mode_line_help_echo,
+ PVEC_WINDOW);
}
/* Make new window, have it replace WINDOW in window-tree, and make
@@ -6710,7 +6710,8 @@ struct save_window_data
Lisp_Object saved_windows;
/* All fields above are traced by the GC.
- From `frame-cols' down, the fields are ignored by the GC. */
+ After saved_windows, the fields are ignored by the GC. */
+
/* We should be able to do without the following two. */
int frame_cols, frame_lines;
/* These two should get eventually replaced by their pixel
@@ -7383,15 +7384,11 @@ redirection (see `redirect-frame-focus'). The variable
saved by this function. */)
(Lisp_Object frame)
{
- Lisp_Object tem;
- ptrdiff_t i, n_windows;
- struct save_window_data *data;
struct frame *f = decode_live_frame (frame);
-
- n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
- data = ALLOCATE_PSEUDOVECTOR (struct save_window_data, frame_cols,
- PVEC_WINDOW_CONFIGURATION);
-
+ ptrdiff_t n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
+ struct save_window_data *data
+ = ALLOCATE_PSEUDOVECTOR (struct save_window_data, saved_windows,
+ PVEC_WINDOW_CONFIGURATION);
data->frame_cols = FRAME_COLS (f);
data->frame_lines = FRAME_LINES (f);
data->frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f);
@@ -7407,9 +7404,9 @@ saved by this function. */)
data->minibuf_selected_window = minibuf_level > 0 ? minibuf_selected_window : Qnil;
data->root_window = FRAME_ROOT_WINDOW (f);
data->focus_frame = FRAME_FOCUS_FRAME (f);
- tem = make_uninit_vector (n_windows);
+ Lisp_Object tem = make_uninit_vector (n_windows);
data->saved_windows = tem;
- for (i = 0; i < n_windows; i++)
+ for (ptrdiff_t i = 0; i < n_windows; i++)
ASET (tem, i, make_nil_vector (VECSIZE (struct saved_window)));
save_window_save (FRAME_ROOT_WINDOW (f), XVECTOR (tem), 0);
XSETWINDOW_CONFIGURATION (tem, data);
diff --git a/src/window.h b/src/window.h
index 4235a6eade2..fdef407041b 100644
--- a/src/window.h
+++ b/src/window.h
@@ -212,9 +212,8 @@ struct window
/* The help echo text for this window. Qnil if there's none. */
Lisp_Object mode_line_help_echo;
- /* No Lisp data may follow below this point without changing
- mark_object in alloc.c. The member current_matrix must be the
- first non-Lisp member. */
+ /* No Lisp data may follow this point; mode_line_help_echo must be
+ the last Lisp member. */
/* Glyph matrices. */
struct glyph_matrix *current_matrix;
diff --git a/src/xterm.c b/src/xterm.c
index 2f830afe61b..5aa3e3ff25c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6611,8 +6611,8 @@ x_scroll_bar_create (struct window *w, int top, int left,
int width, int height, bool horizontal)
{
struct frame *f = XFRAME (w->frame);
- struct scroll_bar *bar
- = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, x_window, PVEC_OTHER);
+ struct scroll_bar *bar = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, prev,
+ PVEC_OTHER);
Lisp_Object barobj;
block_input ();
diff --git a/src/xterm.h b/src/xterm.h
index 972a10f4d41..c5ad38650c2 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -897,7 +897,7 @@ struct scroll_bar
/* The next and previous in the chain of scroll bars in this frame. */
Lisp_Object next, prev;
- /* Fields from `x_window' down will not be traced by the GC. */
+ /* Fields after 'prev' are not traced by the GC. */
/* The X window representing this scroll bar. */
Window x_window;
diff --git a/src/xwidget.c b/src/xwidget.c
index c56284928e3..2486a2d4da8 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -41,14 +41,13 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
static struct xwidget *
allocate_xwidget (void)
{
- return ALLOCATE_PSEUDOVECTOR (struct xwidget, height, PVEC_XWIDGET);
+ return ALLOCATE_PSEUDOVECTOR (struct xwidget, script_callbacks, PVEC_XWIDGET);
}
static struct xwidget_view *
allocate_xwidget_view (void)
{
- return ALLOCATE_PSEUDOVECTOR (struct xwidget_view, redisplayed,
- PVEC_XWIDGET_VIEW);
+ return ALLOCATE_PSEUDOVECTOR (struct xwidget_view, w, PVEC_XWIDGET_VIEW);
}
#define XSETXWIDGET(a, b) XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET)
diff --git a/src/xwidget.h b/src/xwidget.h
index 8c598efb2e2..1b6368daabf 100644
--- a/src/xwidget.h
+++ b/src/xwidget.h
@@ -49,8 +49,7 @@ struct xwidget
/* Vector of currently executing scripts with callbacks. */
Lisp_Object script_callbacks;
-
- /* Here ends the Lisp part. "height" is the marker field. */
+ /* Here ends the Lisp part. script_callbacks is the marker field. */
int height;
int width;
@@ -68,8 +67,7 @@ struct xwidget_view
union vectorlike_header header;
Lisp_Object model;
Lisp_Object w;
-
- /* Here ends the lisp part. "redisplayed" is the marker field. */
+ /* Here ends the lisp part. "w" is the marker field. */
/* If touched by redisplay. */
bool redisplayed;