Skip to content

Commit ff862f5

Browse files
committed
Reverse the meaning of 2nd arg to 'live_buffer_holding'
* src/alloc.c (live_buffer_holding): Rename ALL_BUFFERS ti IGNORE_KILLED, and reverse the condition for returning killed buffers. (live_buffer_p): Add commentary. (live_buffer_p, mark_maybe_object, mark_maybe_pointer): Reverse the 2nd argument to live_buffer_holding. (Bug#39962)
1 parent afaf2f4 commit ff862f5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/alloc.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4596,12 +4596,12 @@ live_vector_p (struct mem_node *m, void *p)
45964596
return !NILP (live_vector_holding (m, p));
45974597
}
45984598

4599-
/* If P is a pointer into a live buffer, return the buffer.
4599+
/* If P is a pointer into a valid buffer object, return the buffer.
46004600
Otherwise, return nil. M is a pointer to the mem_block for P.
4601-
Also return killed buffers if ALL-BUFFERS is true. */
4601+
If IGNORE_KILLED is non-zero, treat killed buffers as invalid. */
46024602

46034603
static Lisp_Object
4604-
live_buffer_holding (struct mem_node *m, void *p, bool all_buffers)
4604+
live_buffer_holding (struct mem_node *m, void *p, bool ignore_killed)
46054605
{
46064606
/* P must point into the block, and the buffer must not
46074607
have been killed unless ALL-BUFFERS is true. */
@@ -4612,7 +4612,7 @@ live_buffer_holding (struct mem_node *m, void *p, bool all_buffers)
46124612
char *cp = p;
46134613
ptrdiff_t offset = cp - cb;
46144614
if (0 <= offset && offset < sizeof *b
4615-
&& (all_buffers || !NILP (b->name_)))
4615+
&& !(ignore_killed && NILP (b->name_)))
46164616
{
46174617
Lisp_Object obj;
46184618
XSETBUFFER (obj, b);
@@ -4622,10 +4622,12 @@ live_buffer_holding (struct mem_node *m, void *p, bool all_buffers)
46224622
return Qnil;
46234623
}
46244624

4625+
/* If P is a pointer into a live (valid and not killed) buffer object,
4626+
return non-zero. */
46254627
static bool
46264628
live_buffer_p (struct mem_node *m, void *p)
46274629
{
4628-
return !NILP (live_buffer_holding (m, p, false));
4630+
return !NILP (live_buffer_holding (m, p, true));
46294631
}
46304632

46314633
/* Mark OBJ if we can prove it's a Lisp_Object. */
@@ -4683,7 +4685,7 @@ mark_maybe_object (Lisp_Object obj)
46834685

46844686
case Lisp_Vectorlike:
46854687
mark_p = (EQ (obj, live_vector_holding (m, po))
4686-
|| EQ (obj, live_buffer_holding (m, po, true)));
4688+
|| EQ (obj, live_buffer_holding (m, po, false)));
46874689
break;
46884690

46894691
default:
@@ -4753,7 +4755,7 @@ mark_maybe_pointer (void *p)
47534755
break;
47544756

47554757
case MEM_TYPE_BUFFER:
4756-
obj = live_buffer_holding (m, p, true);
4758+
obj = live_buffer_holding (m, p, false);
47574759
break;
47584760

47594761
case MEM_TYPE_CONS:

0 commit comments

Comments
 (0)