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 | cfe0428c0d96813685b19a191a3bd20336c20001 (patch) | |
tree | cd26cd6cb6ccbe0788b97650ac18ee8a841a4418 /ffi.c | |
parent | 1cc62e1188538f57b940d45c338d226567dde1ac (diff) | |
download | txr-cfe0428c0d96813685b19a191a3bd20336c20001.tar.gz txr-cfe0428c0d96813685b19a191a3bd20336c20001.tar.bz2 txr-cfe0428c0d96813685b19a191a3bd20336c20001.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.
Diffstat (limited to 'ffi.c')
-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); |