aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <[email protected]>2011-07-06 15:22:32 -0700
committerPaul Eggert <[email protected]>2011-07-06 15:22:32 -0700
commit8a5c77bba5e38c62605f0f053670a7955130fcc7 (patch)
tree1e8151eafcd78b625cd097340d066d79ce5a25f2 /src
parent437dd18bf116330a43585f85aac12e6a8171b8a2 (diff)
Remove more assumptions re struct layout (Bug#8884).
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/alloc.c3
-rw-r--r--src/buffer.c8
3 files changed, 9 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 72a6f875f5..11ba7e0070 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,7 +1,9 @@
2011-07-06 Paul Eggert <[email protected]>
Remove unportable assumption about struct layout (Bug#8884).
- * buffer.c (clone_per_buffer_values): Don't assume that
+ * alloc.c (mark_buffer):
+ * buffer.c (reset_buffer_local_variables, Fbuffer_local_variables)
+ (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.
diff --git a/src/alloc.c b/src/alloc.c
index 43befd722b..f679787e95 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5619,7 +5619,8 @@ mark_buffer (Lisp_Object buf)
/* buffer-local Lisp variables start at `undo_list',
tho only the ones from `name' on are GC'd normally. */
for (ptr = &buffer->BUFFER_INTERNAL_FIELD (name);
- (char *)ptr < (char *)buffer + sizeof (struct buffer);
+ ptr <= &PER_BUFFER_VALUE (buffer,
+ PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER));
ptr++)
mark_object (*ptr);
diff --git a/src/buffer.c b/src/buffer.c
index 6c7c2ec0d8..e2f34d629e 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -830,8 +830,8 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too)
/* 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 *b;
+ for (offset = PER_BUFFER_VAR_OFFSET (FIRST_FIELD_PER_BUFFER);
+ offset <= PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER);
offset += sizeof (Lisp_Object))
{
int idx = PER_BUFFER_IDX (offset);
@@ -1055,8 +1055,8 @@ No argument or nil as argument means use current buffer as BUFFER. */)
/* 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 (struct buffer);
+ for (offset = PER_BUFFER_VAR_OFFSET (FIRST_FIELD_PER_BUFFER);
+ offset <= PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER);
/* sizeof EMACS_INT == sizeof Lisp_Object */
offset += (sizeof (EMACS_INT)))
{