diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-05-03 20:46:36 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-05-03 20:46:36 -0700 |
commit | 5e2ca779638b8aaaab80d3a23be93df3f0555ba2 (patch) | |
tree | 810f4197c9b4aa73ba57128767137d951bc3352f /ffi.c | |
parent | b8b3f6ae7968da399020b9c4ecba2fd433c621fb (diff) | |
download | txr-5e2ca779638b8aaaab80d3a23be93df3f0555ba2.tar.gz txr-5e2ca779638b8aaaab80d3a23be93df3f0555ba2.tar.bz2 txr-5e2ca779638b8aaaab80d3a23be93df3f0555ba2.zip |
ffi: remove put functions which duplicate others.
* ffi.c (ffi_ptr_in_put): Static function removed. It was
functionally identical to ffi_ptr_put, plus a memory leak bug
in the nil object case.
(ffi_ptr_in_d_put): Static function removed, also identical to
ffi_ptr_put.
(ffi_type_compile): Replace references to removed functions
with ffi_ptr_put.
Diffstat (limited to 'ffi.c')
-rw-r--r-- | ffi.c | 33 |
1 files changed, 2 insertions, 31 deletions
@@ -699,20 +699,6 @@ static val ffi_ptr_in_in(struct txr_ffi_type *tft, mem_t *src, val obj, return obj; } -static void ffi_ptr_in_put(struct txr_ffi_type *tft, val s, mem_t *dst, - val self) -{ - val tgttype = tft->mtypes; - struct txr_ffi_type *tgtft = ffi_type_struct(tgttype); - mem_t *buf = tgtft->alloc(tgtft, s, self); - if (s == nil) { - *coerce(mem_t **, dst) = 0; - } else { - tgtft->put(tgtft, s, buf, self); - *coerce(mem_t **, dst) = buf; - } -} - static void ffi_ptr_in_out(struct txr_ffi_type *tft, int copy, val s, mem_t *dst, val self) { @@ -724,21 +710,6 @@ static void ffi_ptr_in_out(struct txr_ffi_type *tft, int copy, val s, } } -static void ffi_ptr_in_d_put(struct txr_ffi_type *tft, val s, mem_t *dst, - val self) -{ - val tgttype = tft->mtypes; - struct txr_ffi_type *tgtft = ffi_type_struct(tgttype); - - if (s == nil) { - *coerce(mem_t **, dst) = 0; - } else { - mem_t *buf = tgtft->alloc(tgtft, s, self); - tgtft->put(tgtft, s, buf, self); - *coerce(mem_t **, dst) = buf; - } -} - static val ffi_ptr_out_in(struct txr_ffi_type *tft, mem_t *src, val obj, val self) { @@ -1289,14 +1260,14 @@ val ffi_type_compile(val syntax) val target_type = ffi_type_compile(cadr(syntax)); return make_ffi_type_pointer(syntax, cptr_s, sizeof (mem_t *), &ffi_type_pointer, - ffi_ptr_in_put, ffi_ptr_get, + ffi_ptr_put, ffi_ptr_get, ffi_ptr_in_in, ffi_ptr_in_out, target_type); } else if (sym == ptr_in_d_s) { val target_type = ffi_type_compile(cadr(syntax)); return make_ffi_type_pointer(syntax, cptr_s, sizeof (mem_t *), &ffi_type_pointer, - ffi_ptr_in_d_put, ffi_ptr_d_get, + ffi_ptr_put, ffi_ptr_d_get, 0, ffi_ptr_in_out, target_type); } else if (sym == ptr_out_s) { |