aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.h
diff options
context:
space:
mode:
authorEli Zaretskii2021-09-22 10:07:25 +0300
committerEli Zaretskii2021-09-22 10:07:25 +0300
commit7973227f67cd8ea4a1ed590ebc279b34ece86c12 (patch)
tree53a0482ef7ef8fd33f34ae9a4cf3e62ddc28227b /src/buffer.h
parent3d575534d43802552f59eb1b990939cb3412d4e9 (diff)
downloademacs-7973227f67cd8ea4a1ed590ebc279b34ece86c12.tar.gz
emacs-7973227f67cd8ea4a1ed590ebc279b34ece86c12.zip
Update comments warning about GC-resistant C programming
* 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>
Diffstat (limited to 'src/buffer.h')
-rw-r--r--src/buffer.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/buffer.h b/src/buffer.h
index 24e9c3fcbc8..8623bed08e6 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -60,6 +60,14 @@ enum { BEG = 1, BEG_BYTE = BEG };
60 60
61/* Macros for the addresses of places in the buffer. */ 61/* Macros for the addresses of places in the buffer. */
62 62
63/* WARNING: Use the 'char *' pointers to buffer text with care in code
64 that could GC: GC can relocate buffer text, invalidating such
65 pointers. It is best to use character or byte position instead,
66 delaying the access through BYTE_POS_ADDR etc. pointers to the
67 latest possible moment. If you must use the 'char *' pointers
68 (e.g., for speed), be sure to adjust them after any call that could
69 potentially GC. */
70
63/* Address of beginning of buffer. */ 71/* Address of beginning of buffer. */
64#define BEG_ADDR (current_buffer->text->beg) 72#define BEG_ADDR (current_buffer->text->beg)
65 73
@@ -1002,6 +1010,9 @@ SET_BUF_PT_BOTH (struct buffer *buf, ptrdiff_t charpos, ptrdiff_t byte)
1002 or convert between a byte position and an address. 1010 or convert between a byte position and an address.
1003 These functions do not check that the position is in range. */ 1011 These functions do not check that the position is in range. */
1004 1012
1013/* See the important WARNING above about using the 'char *' pointers
1014 returned by these functions. */
1015
1005/* Return the address of byte position N in current buffer. */ 1016/* Return the address of byte position N in current buffer. */
1006 1017
1007INLINE unsigned char * 1018INLINE unsigned char *