aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorAndrea Corallo2020-03-16 23:08:47 +0000
committerAndrea Corallo2020-03-16 23:08:47 +0000
commite57d5a71ba765bbd225974b3d61ecd9d80f73220 (patch)
treea9af84fbe39d3d6ad1fc4bf4fa16b5ea170be0c6 /src/alloc.c
parent159f61baa9e374cfd17acf1a45c0d553b57b7ac9 (diff)
parent9dccaf8a5cdb10dae597345ec3741475477a7d97 (diff)
downloademacs-e57d5a71ba765bbd225974b3d61ecd9d80f73220.tar.gz
emacs-e57d5a71ba765bbd225974b3d61ecd9d80f73220.zip
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/alloc.c b/src/alloc.c
index ac173077132..db0646c81e3 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4604,21 +4604,23 @@ live_vector_p (struct mem_node *m, void *p)
4604 return !NILP (live_vector_holding (m, p)); 4604 return !NILP (live_vector_holding (m, p));
4605} 4605}
4606 4606
4607/* If P is a pointer into a live buffer, return the buffer. 4607/* If P is a pointer into a valid buffer object, return the buffer.
4608 Otherwise, return nil. M is a pointer to the mem_block for P. */ 4608 Otherwise, return nil. M is a pointer to the mem_block for P.
4609 If IGNORE_KILLED is non-zero, treat killed buffers as invalid. */
4609 4610
4610static Lisp_Object 4611static Lisp_Object
4611live_buffer_holding (struct mem_node *m, void *p) 4612live_buffer_holding (struct mem_node *m, void *p, bool ignore_killed)
4612{ 4613{
4613 /* P must point into the block, and the buffer 4614 /* P must point into the block, and the buffer must not
4614 must not have been killed. */ 4615 have been killed unless ALL-BUFFERS is true. */
4615 if (m->type == MEM_TYPE_BUFFER) 4616 if (m->type == MEM_TYPE_BUFFER)
4616 { 4617 {
4617 struct buffer *b = m->start; 4618 struct buffer *b = m->start;
4618 char *cb = m->start; 4619 char *cb = m->start;
4619 char *cp = p; 4620 char *cp = p;
4620 ptrdiff_t offset = cp - cb; 4621 ptrdiff_t offset = cp - cb;
4621 if (0 <= offset && offset < sizeof *b && !NILP (b->name_)) 4622 if (0 <= offset && offset < sizeof *b
4623 && !(ignore_killed && NILP (b->name_)))
4622 { 4624 {
4623 Lisp_Object obj; 4625 Lisp_Object obj;
4624 XSETBUFFER (obj, b); 4626 XSETBUFFER (obj, b);
@@ -4628,10 +4630,12 @@ live_buffer_holding (struct mem_node *m, void *p)
4628 return Qnil; 4630 return Qnil;
4629} 4631}
4630 4632
4633/* If P is a pointer into a live (valid and not killed) buffer object,
4634 return non-zero. */
4631static bool 4635static bool
4632live_buffer_p (struct mem_node *m, void *p) 4636live_buffer_p (struct mem_node *m, void *p)
4633{ 4637{
4634 return !NILP (live_buffer_holding (m, p)); 4638 return !NILP (live_buffer_holding (m, p, true));
4635} 4639}
4636 4640
4637/* Mark OBJ if we can prove it's a Lisp_Object. */ 4641/* Mark OBJ if we can prove it's a Lisp_Object. */
@@ -4689,7 +4693,7 @@ mark_maybe_object (Lisp_Object obj)
4689 4693
4690 case Lisp_Vectorlike: 4694 case Lisp_Vectorlike:
4691 mark_p = (EQ (obj, live_vector_holding (m, po)) 4695 mark_p = (EQ (obj, live_vector_holding (m, po))
4692 || EQ (obj, live_buffer_holding (m, po))); 4696 || EQ (obj, live_buffer_holding (m, po, false)));
4693 break; 4697 break;
4694 4698
4695 default: 4699 default:
@@ -4759,7 +4763,7 @@ mark_maybe_pointer (void *p)
4759 break; 4763 break;
4760 4764
4761 case MEM_TYPE_BUFFER: 4765 case MEM_TYPE_BUFFER:
4762 obj = live_buffer_holding (m, p); 4766 obj = live_buffer_holding (m, p, false);
4763 break; 4767 break;
4764 4768
4765 case MEM_TYPE_CONS: 4769 case MEM_TYPE_CONS: