Skip to content

Commit

Permalink
Translate still allocated return values.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferada committed Apr 19, 2014
1 parent 0a2cf1d commit ae89586
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libffi/functions.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
(if (typep (parse-type return-type) 'translatable-foreign-type)
;; just return the pointer so that expand-from-foreign
;; can apply translate-from-foreign
'result
`(translate-from-foreign result (parse-type ',return-type))
;; built-in types won't be translated by
;; expand-from-foreign, we have to do it here
`(mem-aref result ',return-type))))))
Expand Down
6 changes: 4 additions & 2 deletions src/functions.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
(defun translate-objects (syms args types rettype call-form &optional indirect)
"Helper function for FOREIGN-FUNCALL and DEFCFUN. If 'indirect is T, all arguments are represented by foreign pointers, even those that can be represented by CL objects."
(if (null args)
(expand-from-foreign call-form (parse-type rettype))
(if rettype
(expand-from-foreign call-form (parse-type rettype))
call-form)
(funcall
(if indirect
#'expand-to-foreign-dyn-indirect
Expand Down Expand Up @@ -115,7 +117,7 @@
(let ((syms (make-gensym-list (length fargs)))
(fsbvp (fn-call-by-value-p ctypes rettype)))
(translate-objects
syms fargs types rettype
syms fargs types (unless fsbvp rettype)
(if fsbvp
;; Structures by value call through *foreign-structures-by-value*
(funcall *foreign-structures-by-value*
Expand Down

0 comments on commit ae89586

Please sign in to comment.