Commit 97cfda26 authored by Paul Eggert's avatar Paul Eggert

Take last_per_buffer_idx private

This will simplify future changes.  Turn the runtime check
into an eassert, since it’s not needed in production.
* src/buffer.c (last_per_buffer_idx): Now static.
(valid_per_buffer_idx): New function.
* src/buffer.h (PER_BUFFER_VALUE_P, SET_PER_BUFFER_VALUE_P): Use it.
parent 9117a667
......@@ -105,7 +105,7 @@ static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS];
/* Number of per-buffer variables used. */
int last_per_buffer_idx;
static int last_per_buffer_idx;
static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay,
bool after, Lisp_Object arg1,
......@@ -655,6 +655,12 @@ set_buffer_overlays_after (struct buffer *b, struct Lisp_Overlay *o)
b->overlays_after = o;
}
bool
valid_per_buffer_idx (int idx)
{
return 0 <= idx && idx < last_per_buffer_idx;
}
/* Clone per-buffer values of buffer FROM.
Buffer TO gets the same per-buffer values as FROM, with the
......
......@@ -1268,10 +1268,6 @@ buffer_window_count (struct buffer *b)
Buffer-local Variables
***********************************************************************/
/* Number of per-buffer variables used. */
extern int last_per_buffer_idx;
/* Return the offset in bytes of member VAR of struct buffer
from the start of a buffer structure. */
......@@ -1296,23 +1292,21 @@ extern int last_per_buffer_idx;
#define PER_BUFFER_VAR_IDX(VAR) \
PER_BUFFER_IDX (PER_BUFFER_VAR_OFFSET (VAR))
extern bool valid_per_buffer_idx (int);
/* Value is true if the variable with index IDX has a local value
in buffer B. */
#define PER_BUFFER_VALUE_P(B, IDX) \
(((IDX) < 0 || IDX >= last_per_buffer_idx) \
? (emacs_abort (), false) \
: ((B)->local_flags[IDX] != 0))
(eassert (valid_per_buffer_idx (IDX)), \
(B)->local_flags[IDX])
/* Set whether per-buffer variable with index IDX has a buffer-local
value in buffer B. VAL zero means it hasn't. */
#define SET_PER_BUFFER_VALUE_P(B, IDX, VAL) \
do { \
if ((IDX) < 0 || (IDX) >= last_per_buffer_idx) \
emacs_abort (); \
(B)->local_flags[IDX] = (VAL); \
} while (false)
(eassert (valid_per_buffer_idx (IDX)), \
(B)->local_flags[IDX] = (VAL))
/* Return the index value of the per-buffer variable at offset OFFSET
in the buffer structure.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment