aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/alloc.c b/src/alloc.c
index f12fdc5c861..7c560fd0f0d 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2066,20 +2066,21 @@ Lisp_Object
2066make_uninit_bool_vector (EMACS_INT nbits) 2066make_uninit_bool_vector (EMACS_INT nbits)
2067{ 2067{
2068 Lisp_Object val; 2068 Lisp_Object val;
2069 struct Lisp_Bool_Vector *p; 2069 EMACS_INT words0 = bool_vector_words (nbits);
2070 EMACS_INT word_bytes, needed_elements; 2070 EMACS_INT words = words0 + !words0; /* Allocate at least one word. */
2071 word_bytes = bool_vector_words (nbits) * sizeof (bits_word); 2071 EMACS_INT word_bytes = words * sizeof (bits_word);
2072 needed_elements = ((bool_header_size - header_size + word_bytes 2072 EMACS_INT needed_elements = ((bool_header_size - header_size + word_bytes
2073 + word_size - 1) 2073 + word_size - 1)
2074 / word_size); 2074 / word_size);
2075 p = (struct Lisp_Bool_Vector *) allocate_vector (needed_elements); 2075 struct Lisp_Bool_Vector *p
2076 = (struct Lisp_Bool_Vector *) allocate_vector (needed_elements);
2076 XSETVECTOR (val, p); 2077 XSETVECTOR (val, p);
2077 XSETPVECTYPESIZE (XVECTOR (val), PVEC_BOOL_VECTOR, 0, 0); 2078 XSETPVECTYPESIZE (XVECTOR (val), PVEC_BOOL_VECTOR, 0, 0);
2078 p->size = nbits; 2079 p->size = nbits;
2079 2080
2080 /* Clear padding at the end. */ 2081 /* Clear padding at the end. If NBITS != 0 this initializes more
2081 if (nbits) 2082 than it needs to, but that's OK. */
2082 p->data[bool_vector_words (nbits) - 1] = 0; 2083 p->data[words - 1] = 0;
2083 2084
2084 return val; 2085 return val;
2085} 2086}