From 3c78e9ea75c2c28bafbc598a6c1c1f615ea63623 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 7 May 2017 19:45:17 -0700 Subject: ffi: varray: write out all elements of Lisp seq. * ffi.c (ffi_array_put, ffi_array_out): If dealign with a variable array that is null terminated, let's add one to nelem, so that all elements of the Lisp sequence are converted, and then a null. --- ffi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ffi.c b/ffi.c index d194a9bf..6c831246 100644 --- a/ffi.c +++ b/ffi.c @@ -1070,8 +1070,8 @@ static void ffi_array_put(struct txr_ffi_type *tft, val vec, mem_t *dst, val eltype = tft->mtypes; struct txr_ffi_type *etft = ffi_type_struct(eltype); cnum elsize = etft->size; - cnum i, nelem = if3(tft->is_varray, c_num(length(vec)), tft->nelem); int nt = tft->null_term; + cnum i, nelem = if3(tft->is_varray, c_num(length(vec)) + nt, tft->nelem); ucnum offs = 0; for (i = 0; i < nelem; i++) { @@ -1092,8 +1092,8 @@ static void ffi_array_out(struct txr_ffi_type *tft, int copy, val vec, val eltype = tft->mtypes; struct txr_ffi_type *etft = ffi_type_struct(eltype); cnum elsize = etft->size; - cnum i, nelem = if3(tft->is_varray, c_num(length(vec)), tft->nelem); int nt = tft->null_term; + cnum i, nelem = if3(tft->is_varray, c_num(length(vec)) + nt, tft->nelem); ucnum offs = 0; for (i = 0; i < nelem; i++) { -- cgit v1.2.3