diff options
author | Andy Wingo <wingo@pobox.com> | 2014-03-19 22:41:19 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2014-03-19 22:41:19 +0100 |
commit | 2be7131ee0c38336483226657872a8faa62a2562 (patch) | |
tree | 40d99ccd801da7a47c8448777873eb3fb0de11fe /libguile/srfi-4.c | |
parent | 92b793da2b43af0ed470c43dc7e41409ca61f1b4 (diff) | |
download | guile-2be7131ee0c38336483226657872a8faa62a2562.tar.gz |
Fix breakage of SRFI-4 C accessors
* libguile/srfi-4.c (DEFINE_SRFI_4_C_FUNCS): Fix bad assumption that
width was a byte width. Thanks very much to Barry Fishman for the
report, and to Daniel Llorens for tracking it down.
* test-suite/standalone/Makefile.am (test_srfi_4_CFLAGS):
* test-suite/standalone/test-srfi-4.c: Add test.
Diffstat (limited to 'libguile/srfi-4.c')
-rw-r--r-- | libguile/srfi-4.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libguile/srfi-4.c b/libguile/srfi-4.c index 7b25a3b4d..8257b2e45 100644 --- a/libguile/srfi-4.c +++ b/libguile/srfi-4.c @@ -137,12 +137,13 @@ scm_t_array_handle *h, \ size_t *lenp, ssize_t *incp) \ { \ + size_t byte_width = width * sizeof (ctype); \ if (!scm_is_bytevector (uvec) \ - || (scm_c_bytevector_length (uvec) % width)) \ + || (scm_c_bytevector_length (uvec) % byte_width)) \ scm_wrong_type_arg_msg (NULL, 0, uvec, #tag "vector"); \ scm_array_get_handle (uvec, h); \ if (lenp) \ - *lenp = scm_c_bytevector_length (uvec) / width; \ + *lenp = scm_c_bytevector_length (uvec) / byte_width; \ if (incp) \ *incp = 1; \ return ((ctype *)h->writable_elements); \ |