diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-05-10 20:20:12 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-05-10 20:20:12 -0700 |
commit | b829bb25d84940ee1d04d6e4983bb06d29091a29 (patch) | |
tree | af986b26080a4c04728437386e5ba770f03bc4ef /ffi.c | |
parent | 2e0385880600fb0edee85a8960ed3160086a42f1 (diff) | |
download | txr-b829bb25d84940ee1d04d6e4983bb06d29091a29.tar.gz txr-b829bb25d84940ee1d04d6e4983bb06d29091a29.tar.bz2 txr-b829bb25d84940ee1d04d6e4983bb06d29091a29.zip |
ffi: bugfix: use nelem, not size, in array in and get.
Arrays can be varray, whose size is just pointer size.
The string extraction operations shouldn't be referring
to the size.
* ffi.c (ffi_array_in, ffi_array_et): Use nelem instead
of tft->size.
Diffstat (limited to 'ffi.c')
-rw-r--r-- | ffi.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1011,7 +1011,7 @@ static val ffi_array_in(struct txr_ffi_type *tft, int copy, mem_t *src, if (tft->null_term) { str = string_utf8(chptr); } else { - wchar_t *wch = utf8_dup_from_buf(chptr, tft->size); + wchar_t *wch = utf8_dup_from_buf(chptr, nelem); str = string_own(wch); } } @@ -1042,7 +1042,7 @@ static val ffi_array_in(struct txr_ffi_type *tft, int copy, mem_t *src, if (tft->null_term) str = string_8bit(chptr); else - str = string_8bit_size(chptr, tft->size); + str = string_8bit_size(chptr, nelem); } vec = if3(vec, replace(vec, str, zero, t), str); } else { @@ -1131,7 +1131,7 @@ static val ffi_array_get(struct txr_ffi_type *tft, mem_t *src, val self) if (tft->null_term) { return string_utf8(chptr); } else { - wchar_t *wch = utf8_dup_from_buf(chptr, tft->size); + wchar_t *wch = utf8_dup_from_buf(chptr, tft->nelem); return string_own(wch); } } @@ -1156,7 +1156,7 @@ static val ffi_array_get(struct txr_ffi_type *tft, mem_t *src, val self) if (tft->null_term) return string_8bit(chptr); else - return string_8bit_size(chptr, tft->size); + return string_8bit_size(chptr, nelem); } } else { cnum znelem = if3(tft->null_term && nelem > 0, nelem - 1, nelem); |