diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2021-02-16 17:24:38 +0100 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2021-02-16 17:24:38 +0100 |
commit | fbacc1e2472fdb1d898e10a227fac91962464cf8 (patch) | |
tree | c5cbced6b5f106b91c7255118715faa648caf0ac | |
parent | 7b07dd6c9ec599dc902513bcaf3c66662ed6b9c4 (diff) |
low: make-cstr-array: Simplify and fix off-by-one error.
-rw-r--r-- | drmaa/v1/low.scm | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drmaa/v1/low.scm b/drmaa/v1/low.scm index 97e9a67..52d37f3 100644 --- a/drmaa/v1/low.scm +++ b/drmaa/v1/low.scm @@ -85,15 +85,15 @@ STRING-LIST." (let* ((n (length string-list)) (pointers (map string->pointer string-list)) (addresses (map pointer-address pointers)) - (bv (make-bytevector (* (1+ n) (sizeof '*)))) + ;; Make it one item longer, because it needs to be a + ;; NULL-terminated array. + (bv (make-bytevector (* (1+ n) (sizeof '*)) 0)) (bv-set! (case (sizeof '*) ((4) bytevector-u32-native-set!) ((8) bytevector-u64-native-set!)))) (for-each (lambda (address index) (bv-set! bv (* (sizeof '*) index) address)) addresses (iota n)) - ;; The vector must be NULL-terminated - (bv-set! bv (* (1+ n) (sizeof '*)) 0) bv)) (define-syntax-rule (return ret success error-message) |