summaryrefslogtreecommitdiffstats
path: root/ffi.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-05-07 19:45:17 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-05-07 19:45:17 -0700
commitb00727089e36a75ed86160cba51695689d9a38d5 (patch)
treec2a5c0e978854041234515ea1529974da83d286d /ffi.c
parent43275967b547f72dcb2f41c698c64575e1374214 (diff)
downloadtxr-b00727089e36a75ed86160cba51695689d9a38d5.tar.gz
txr-b00727089e36a75ed86160cba51695689d9a38d5.tar.bz2
txr-b00727089e36a75ed86160cba51695689d9a38d5.zip
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.
Diffstat (limited to 'ffi.c')
-rw-r--r--ffi.c4
1 files 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++) {