mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-07 06:50:23 -08:00
Avoid accessing uninitialized bool_vector words
Although loading uninitialized works from memory and then ignoring the result works fine on conventional architectures, it technically has undefined behavior in C, so redo bool_vector allocation so that the code never does that. This can improve performance when allocating large vectors of nil, since calloc can clear the memory lazily. * src/alloc.c (make_clear_bool_vector): New function, a generalization of make_uninit_bool_vector. (make_uninit_bool_vector): Use it. (Fmake_bool_vector): If !INIT, rely on make_clear_bool_vector. * src/alloc.c (Fbool_vector): * src/fns.c (Freverse): Don’t access uninitialized bool_vector words.
This commit is contained in:
parent
cb78b43f39
commit
79b9f05d3a
3 changed files with 30 additions and 23 deletions
|
|
@ -4578,6 +4578,7 @@ list4i (intmax_t a, intmax_t b, intmax_t c, intmax_t d)
|
|||
return list4 (make_int (a), make_int (b), make_int (c), make_int (d));
|
||||
}
|
||||
|
||||
extern Lisp_Object make_clear_bool_vector (EMACS_INT, bool);
|
||||
extern Lisp_Object make_uninit_bool_vector (EMACS_INT);
|
||||
extern Lisp_Object bool_vector_fill (Lisp_Object, Lisp_Object);
|
||||
extern AVOID string_overflow (void);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue