summaryrefslogtreecommitdiff
path: root/libguile/bytevectors.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-10-16 11:59:30 +0200
committerAndy Wingo <wingo@pobox.com>2009-10-16 11:59:30 +0200
commitb0fae4ecaa9f602f3183c35eb945c8050e1f3b68 (patch)
treed4aeb48a6f1d2778adb1f549c0de50a37c95101a /libguile/bytevectors.c
parent96e15df109ccfdcc2f6b2cffc0b64a083f000903 (diff)
downloadguile-b0fae4ecaa9f602f3183c35eb945c8050e1f3b68.tar.gz
bitvector tweaks
* libguile/arrays.c (scm_from_contiguous_typed_array): * libguile/bytevectors.c (scm_uniform_array_to_bytevector): Error if the uniform element size is more than 8 bits, but not divisible by 8 -- because our math could overflow in that case. * module/ice-9/deprecated.scm (#\y): Indeed, #* is the valid bitvector syntax :)
Diffstat (limited to 'libguile/bytevectors.c')
-rw-r--r--libguile/bytevectors.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c
index e0998197c..b9d2d8926 100644
--- a/libguile/bytevectors.c
+++ b/libguile/bytevectors.c
@@ -604,9 +604,12 @@ SCM_DEFINE (scm_uniform_array_to_bytevector, "uniform-array->bytevector",
sz = scm_array_handle_uniform_element_bit_size (&h);
if (sz >= 8 && ((sz % 8) == 0))
byte_len = len * (sz / 8);
- else
+ else if (sz < 8)
/* byte_len = ceil (len * sz / 8) */
byte_len = (len * sz + 7) / 8;
+ else
+ /* an internal guile error, really */
+ SCM_MISC_ERROR ("uniform elements larger than 8 bits must fill whole bytes", SCM_EOL);
ret = make_bytevector (byte_len, SCM_ARRAY_ELEMENT_TYPE_VU8);
memcpy (SCM_BYTEVECTOR_CONTENTS (ret), elts, byte_len);