From 22b4128ef0160a0fab35a5d6dfc0f6a55c8bad93 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 6 Jul 2011 14:53:56 -0700 Subject: [PATCH] Remove unportable assumption about struct layout (Bug#8884). * buffer.c (clone_per_buffer_values): Don't assume that sizeof (struct buffer) is a multiple of sizeof (Lisp_Object). This isn't true in general, and it's particularly not true if Emacs is configured with --with-wide-int. * buffer.h (FIRST_FIELD_PER_BUFFER, LAST_FIELD_PER_BUFFER): New macros, used in the buffer.c change. --- src/ChangeLog | 10 ++++++++++ src/buffer.c | 4 ++-- src/buffer.h | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index dc62da2035b..72a6f875f53 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2011-07-06 Paul Eggert + + Remove unportable assumption about struct layout (Bug#8884). + * buffer.c (clone_per_buffer_values): Don't assume that + sizeof (struct buffer) is a multiple of sizeof (Lisp_Object). + This isn't true in general, and it's particularly not true + if Emacs is configured with --with-wide-int. + * buffer.h (FIRST_FIELD_PER_BUFFER, LAST_FIELD_PER_BUFFER): + New macros, used in the buffer.c change. + 2011-07-05 Jan Djärv * xsettings.c: Use both GConf and GSettings if both are available. diff --git a/src/buffer.c b/src/buffer.c index 2339416eb36..6c7c2ec0d86 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -471,8 +471,8 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to) /* buffer-local Lisp variables start at `undo_list', tho only the ones from `name' on are GC'd normally. */ - for (offset = PER_BUFFER_VAR_OFFSET (undo_list); - offset < sizeof *to; + for (offset = PER_BUFFER_VAR_OFFSET (FIRST_FIELD_PER_BUFFER); + offset <= PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER); offset += sizeof (Lisp_Object)) { Lisp_Object obj; diff --git a/src/buffer.h b/src/buffer.h index 4643e0d9d0e..06864dd5789 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -612,6 +612,7 @@ struct buffer /* Everything from here down must be a Lisp_Object. */ /* buffer-local Lisp variables start at `undo_list', tho only the ones from `name' on are GC'd normally. */ + #define FIRST_FIELD_PER_BUFFER undo_list /* Changes in the buffer are recorded here for undo. t means don't record anything. @@ -846,6 +847,9 @@ struct buffer t means to use hollow box cursor. See `cursor-type' for other values. */ Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows); + + /* This must be the last field in the above list. */ + #define LAST_FIELD_PER_BUFFER cursor_in_non_selected_windows }; -- 2.39.2