[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/comp-static-data 80ea23618da 06/16: Avoid directly accessing the
From: |
Vibhav Pant |
Subject: |
scratch/comp-static-data 80ea23618da 06/16: Avoid directly accessing the size field in a Lisp String. |
Date: |
Thu, 19 Jan 2023 12:44:35 -0500 (EST) |
branch: scratch/comp-static-data
commit 80ea23618da0e06a70c6f1063327ff8781dc0fc4
Author: Vibhav Pant <vibhavp@gmail.com>
Commit: Vibhav Pant <vibhavp@gmail.com>
Avoid directly accessing the size field in a Lisp String.
* src/lisp.h (STRING_CHARS): New function.
* src/casefiddle.c (case_character_impl): Use STRING_CHARS to get the
number of characters for str.
---
src/casefiddle.c | 2 +-
src/lisp.h | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/casefiddle.c b/src/casefiddle.c
index e8ae2e276fc..d3df3390f3f 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -140,7 +140,7 @@ case_character_impl (struct casing_str_buf *buf,
struct Lisp_String *str = XSTRING (prop);
if (STRING_BYTES (str) <= sizeof buf->data)
{
- buf->len_chars = str->u.s.size;
+ buf->len_chars = STRING_CHARS (str);
buf->len_bytes = STRING_BYTES (str);
memcpy (buf->data, str->u.s.data, buf->len_bytes);
return 1;
diff --git a/src/lisp.h b/src/lisp.h
index 2ceffd47345..a0b42c3a6a3 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1740,6 +1740,17 @@ STRING_BYTES (struct Lisp_String *s)
return nbytes;
}
+INLINE ptrdiff_t
+STRING_CHARS (struct Lisp_String *s)
+{
+ ptrdiff_t nchars = s->u.s.size;
+#ifdef HAVE_STATIC_LISP_GLOBALS
+ nchars &= ~ARRAY_MARK_FLAG;
+#endif
+ eassume (0 <= nchars);
+ return nchars;
+}
+
INLINE ptrdiff_t
SBYTES (Lisp_Object string)
{
- scratch/comp-static-data updated (e7459fcbde4 -> b67b328d6ab), Vibhav Pant, 2023/01/19
- scratch/comp-static-data 0246e122df8 04/16: Avoid accessing Lisp_Vector's size field directly., Vibhav Pant, 2023/01/19
- scratch/comp-static-data 80ea23618da 06/16: Avoid directly accessing the size field in a Lisp String.,
Vibhav Pant <=
- scratch/comp-static-data 7727f85b869 07/16: src/.gdbinit: Add pretty-printing support for native comp units., Vibhav Pant, 2023/01/19
- scratch/comp-static-data 83c49e2f376 01/16: Avoid additional recursion while marking natively compiled unit., Vibhav Pant, 2023/01/19
- scratch/comp-static-data ab886f48966 05/16: comp.c: Only call comp_init_objs when not recursively loading., Vibhav Pant, 2023/01/19
- scratch/comp-static-data 4a0854c9e32 03/16: src/alloc.c: Unmark Lisp Vectors when accessing the size field., Vibhav Pant, 2023/01/19
- scratch/comp-static-data a0bd3b7d32a 02/16: src/alloc.c: Remove unnecessary calls to static_comp_object_p., Vibhav Pant, 2023/01/19
- scratch/comp-static-data 6bf897449b6 09/16: src/comp.c: Disable native compiling certain bytecode forms for now., Vibhav Pant, 2023/01/19
- scratch/comp-static-data fb3a68c171e 12/16: ; src/comp.c: Fix typo in call to comp-func-byte-func., Vibhav Pant, 2023/01/19
- scratch/comp-static-data 99896f21267 10/16: Merge branch 'master' into scratch/comp-static-data, Vibhav Pant, 2023/01/19
- scratch/comp-static-data 87909765da7 13/16: comp.el: Avoid unnecessary allocation of byte-code forms., Vibhav Pant, 2023/01/19
- scratch/comp-static-data 485f868bbfe 14/16: src/alloc.c: Improve checks in static_comp_object_p., Vibhav Pant, 2023/01/19