mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-22 04:21:16 -08:00
ffi: protect with-foreign-string and with-foreign-object against interrupts
This commit is contained in:
parent
a34b6d0ca4
commit
2192e63e59
1 changed files with 9 additions and 8 deletions
|
|
@ -504,11 +504,11 @@ FREE-FOREIGN-OBJECT. Initial contents of the string are undefined."
|
|||
|
||||
Binds FOREIGN-STRING to a foreign string created from conversion of a
|
||||
STRING and evaluated the BODY. Automatically frees the FOREIGN-STRING."
|
||||
(let ((result (gensym)))
|
||||
`(let* ((,foreign-string (convert-to-foreign-string ,lisp-string))
|
||||
(,result (progn ,@body)))
|
||||
(free-foreign-object ,foreign-string)
|
||||
,result)))
|
||||
`(let* ((,foreign-string (convert-to-foreign-string ,lisp-string)))
|
||||
(mp:without-interrupts
|
||||
(unwind-protect
|
||||
(mp:with-restored-interrupts ,@body)
|
||||
(free-foreign-object ,foreign-string)))))
|
||||
|
||||
(defmacro with-foreign-strings (bindings &rest body)
|
||||
"Syntax: (with-foreign-strings ((foreign-string string)*) &body body)
|
||||
|
|
@ -530,9 +530,10 @@ See: WITH-FOREIGN-STRING. Works similar to LET*."
|
|||
Wraps the allocation, binding and destruction of a foreign object
|
||||
around a body of code"
|
||||
`(let ((,var (allocate-foreign-object ,type)))
|
||||
(unwind-protect
|
||||
(progn ,@body)
|
||||
(free-foreign-object ,var))))
|
||||
(mp:without-interrupts
|
||||
(unwind-protect
|
||||
(mp:with-restored-interrupts ,@body)
|
||||
(free-foreign-object ,var)))))
|
||||
|
||||
(defmacro with-foreign-objects (bindings &rest body)
|
||||
(if bindings
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue