Guest User

Untitled

a guest
May 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. (defmacro with-double-ptr ((inner outer c-type) &body body)
  2. "Creates a pointer INNER (ostensibly of type C-TYPE) which is addressed by OUTER. Only OUTER is deallocated.
  3. This is intended for use with functions which set take a pointer to a pointer and set the inner pointer's value to the address of some C-TYPE. Note that no typechecking is done."
  4. `(let ((,inner (make-pointer 0)))
  5. (with-foreign-object (,outer '(:pointer ,c-type))
  6. (setf (mem-ref ,outer :pointer) ,inner)
  7. ,@body)))
  8.  
  9. (defmacro with-double-ptr-wfo ((inner outer c-type) &body body)
  10. "Creates a pointer INNER (ostensibly of type C-TYPE) which is addressed by OUTER."
  11. `(with-foreign-objects ((,inner ',c-type)
  12. (,outer '(:pointer ,c-type)))
  13. (setf (mem-ref ,outer :pointer) ,inner)
  14. ,@body))
Add Comment
Please, Sign In to add comment