Skip to content

Commit

Permalink
use jcall-raw in %foreign-alloc and foreign-free
Browse files Browse the repository at this point in the history
 * but cheat and return nil in foreign-free because that's what it's supposed to return

--HG--
extra : source : e799a650f5f4376b1839b836a2646d7a55598fbc
  • Loading branch information
slyrus committed Apr 18, 2014
1 parent 5487773 commit dc60e30
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/cffi-abcl.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,14 @@
(defun %foreign-alloc (size)
"Allocate SIZE bytes on the heap and return a pointer."
(make-pointer
(jcall (private-jmethod "com.sun.jna.Memory" "malloc")
nil size)))
(jcall-raw (private-jmethod "com.sun.jna.Memory" "malloc")
nil size)))

(defun foreign-free (ptr)
"Free a PTR allocated by FOREIGN-ALLOC."
(jcall (private-jmethod "com.sun.jna.Memory" "free")
nil (%pointer-address ptr)))
(jcall-raw (private-jmethod "com.sun.jna.Memory" "free")
nil (%pointer-address ptr))
nil)

;;; TODO: stack allocation.
(defmacro with-foreign-pointer ((var size &optional size-var) &body body)
Expand Down

0 comments on commit dc60e30

Please sign in to comment.