diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-07-28 15:26:58 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-07-28 15:26:58 -0700 |
commit | bb25060d2ac6ddd3ff3be149f3a6f3c00eab1182 (patch) | |
tree | cd26cd6cb6ccbe0788b97650ac18ee8a841a4418 | |
parent | 0ef07118ef3b678306d8e7ba6308c1355e013bef (diff) | |
download | txr-bb25060d2ac6ddd3ff3be149f3a6f3c00eab1182.tar.gz txr-bb25060d2ac6ddd3ff3be149f3a6f3c00eab1182.tar.bz2 txr-bb25060d2ac6ddd3ff3be149f3a6f3c00eab1182.zip |
FFI: bugfix: properly re-use existing struct type.
This is a bug in the prior commit's change.
* ffi.c (make_ffi_type_struct, make_ffi_type_union): When
using an existing type, do not call cobj to make a new Lisp
object for the type structure; pull the existing one out
from tft->self.
-rw-r--r-- | ffi.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -2843,7 +2843,9 @@ static val make_ffi_type_struct(val syntax, val lisp_type, cnum nmemb = c_num(length(slot_exprs)), i; struct smemb *memb = coerce(struct smemb *, chk_calloc(nmemb, sizeof *memb)); - val obj = cobj(coerce(mem_t *, tft), ffi_type_s, &ffi_type_struct_ops); + val obj = if3(use_existing, + tft->self, + cobj(coerce(mem_t *, tft), ffi_type_s, &ffi_type_struct_ops)); ucnum offs = 0; ucnum most_align = 0; int need_out_handler = 0; @@ -3006,7 +3008,9 @@ static val make_ffi_type_union(val syntax, val use_existing, val self) cnum nmemb = c_num(length(slot_exprs)), i; struct smemb *memb = coerce(struct smemb *, chk_calloc(nmemb, sizeof *memb)); - val obj = cobj(coerce(mem_t *, tft), ffi_type_s, &ffi_type_struct_ops); + val obj = if3(use_existing, + tft->self, + cobj(coerce(mem_t *, tft), ffi_type_s, &ffi_type_struct_ops)); ucnum most_align = 0; ucnum biggest_size = 0; const unsigned bits_int = 8 * sizeof(int); |