diff options
| author | Richard M. Stallman | 1998-05-05 19:30:33 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-05-05 19:30:33 +0000 |
| commit | a558a05d61acede40cb8f11fb1d2d74f1f142846 (patch) | |
| tree | 100f69b7047beb8c3d25b4294300dc3b8864428b /src/alloc.c | |
| parent | ef1c5063e5001c4f67ffad019cea354fbcd55960 (diff) | |
| download | emacs-a558a05d61acede40cb8f11fb1d2d74f1f142846.tar.gz emacs-a558a05d61acede40cb8f11fb1d2d74f1f142846.zip | |
(Fmake_bool_vector): Clear out extraneous bits at end.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c index b41af98ac4f..e010f8501bc 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.") | |||
| 1237 | bits_per_value = sizeof (EMACS_INT) * BITS_PER_CHAR; | 1237 | bits_per_value = sizeof (EMACS_INT) * BITS_PER_CHAR; |
| 1238 | 1238 | ||
| 1239 | length_in_elts = (XFASTINT (length) + bits_per_value - 1) / bits_per_value; | 1239 | length_in_elts = (XFASTINT (length) + bits_per_value - 1) / bits_per_value; |
| 1240 | length_in_chars = length_in_elts * sizeof (EMACS_INT); | 1240 | length_in_chars = ((XFASTINT (length) + BITS_PER_CHAR - 1) / BITS_PER_CHAR); |
| 1241 | 1241 | ||
| 1242 | /* We must allocate one more elements than LENGTH_IN_ELTS for the | 1242 | /* We must allocate one more elements than LENGTH_IN_ELTS for the |
| 1243 | slot `size' of the struct Lisp_Bool_Vector. */ | 1243 | 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.") | |||
| 1251 | real_init = (NILP (init) ? 0 : -1); | 1251 | real_init = (NILP (init) ? 0 : -1); |
| 1252 | for (i = 0; i < length_in_chars ; i++) | 1252 | for (i = 0; i < length_in_chars ; i++) |
| 1253 | p->data[i] = real_init; | 1253 | p->data[i] = real_init; |
| 1254 | /* Clear the extraneous bits in the last byte. */ | ||
| 1255 | if (XINT (length) != length_in_chars * BITS_PER_CHAR) | ||
| 1256 | XBOOL_VECTOR (val)->data[length_in_chars - 1] | ||
| 1257 | &= (1 << (XINT (length) % BITS_PER_CHAR)) - 1; | ||
| 1254 | 1258 | ||
| 1255 | return val; | 1259 | return val; |
| 1256 | } | 1260 | } |