aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorRichard M. Stallman <[email protected]>1998-05-05 19:30:33 +0000
committerRichard M. Stallman <[email protected]>1998-05-05 19:30:33 +0000
commita558a05d61acede40cb8f11fb1d2d74f1f142846 (patch)
tree100f69b7047beb8c3d25b4294300dc3b8864428b /src/alloc.c
parentef1c5063e5001c4f67ffad019cea354fbcd55960 (diff)
(Fmake_bool_vector): Clear out extraneous bits at end.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c
index b41af98ac4..e010f8501b 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1237,7 +1237,7 @@ LENGTH must be a number. INIT matters only in whether it is t or nil.")
bits_per_value = sizeof (EMACS_INT) * BITS_PER_CHAR;
length_in_elts = (XFASTINT (length) + bits_per_value - 1) / bits_per_value;
- length_in_chars = length_in_elts * sizeof (EMACS_INT);
+ length_in_chars = ((XFASTINT (length) + BITS_PER_CHAR - 1) / BITS_PER_CHAR);
/* We must allocate one more elements than LENGTH_IN_ELTS for the
slot `size' of the struct Lisp_Bool_Vector. */
@@ -1251,6 +1251,10 @@ LENGTH must be a number. INIT matters only in whether it is t or nil.")
real_init = (NILP (init) ? 0 : -1);
for (i = 0; i < length_in_chars ; i++)
p->data[i] = real_init;
+ /* Clear the extraneous bits in the last byte. */
+ if (XINT (length) != length_in_chars * BITS_PER_CHAR)
+ XBOOL_VECTOR (val)->data[length_in_chars - 1]
+ &= (1 << (XINT (length) % BITS_PER_CHAR)) - 1;
return val;
}