/* 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,
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
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. */
#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.