* src/eval.c: Remove an outdated comment about protection from GC.
* src/buffer.h:
* src/lisp.h: Add warnings about using 'char *' pointers to text
of Lisp strings and buffer text in code that could GC. Reported by
Po Lu <luangruo@yahoo.com>
/* Macros for the addresses of places in the buffer. */
+/* WARNING: Use the 'char *' pointers to buffer text with care in code
+ that could GC: GC can relocate buffer text, invalidating such
+ pointers. It is best to use character or byte position instead,
+ delaying the access through BYTE_POS_ADDR etc. pointers to the
+ latest possible moment. If you must use the 'char *' pointers
+ (e.g., for speed), be sure to adjust them after any call that could
+ potentially GC. */
+
/* Address of beginning of buffer. */
#define BEG_ADDR (current_buffer->text->beg)
or convert between a byte position and an address.
These functions do not check that the position is in range. */
+/* See the important WARNING above about using the 'char *' pointers
+ returned by these functions. */
+
/* Return the address of byte position N in current buffer. */
INLINE unsigned char *
call_debugger (list1 (code));
}
\f
-/* NOTE!!! Every function that can call EVAL must protect its args
- and temporaries from garbage collection while it needs them.
- The definition of `For' shows what you have to do. */
DEFUN ("or", For, Sor, 0, UNEVALLED, 0,
doc: /* Eval args until one of them yields non-nil, then return that value.
/* Convenience functions for dealing with Lisp strings. */
+/* WARNING: Use the 'char *' pointers to string data with care in code
+ that could GC: GC can relocate string data, invalidating such
+ pointers. It is best to use string character or byte index
+ instead, delaying the access through SDATA/SSDATA pointers to the
+ latest possible moment. If you must use the 'char *' pointers
+ (e.g., for speed), be sure to adjust them after any call that could
+ potentially GC. */
+
INLINE unsigned char *
SDATA (Lisp_Object string)
{