NextPrevUpTopContentsIndex

with-dynamic-foreign-objects-with-cleanups

Macro
Summary

Allocates memory for a list of foreign objects, executes a list of forms which may use the objects across the scope of the macro, and then deallocates the foreign objects.

Package

fli

Signature

with-dynamic-foreign-objects-with-cleanups bindings form &rest cleanups => result

Arguments

bindings

A list of variable bindings.

form

A single form to be executed with bindings in effect.

cleanups

A list of forms.

Values

result

The value of form .

Description

The macro with-dynamic-foreign-objects-with-cleanups allocates memory for foreign objects specified in bindings , executes form (which may use those objects) and then executes cleanups before deallocating the foreign objects. This is the same effect as with-dynamic-foreign-objects, but it also allows you to add cleanup forms cleanups that are guaranteed to be executed (as in unwind-protect ).

There are two differences between using this and using with-dynamic-foreign-objects with a body is that is a single unwind-protect form where cleanups are the cleanup-forms of the unwind-protect , like this:

(fli:with-dynamic-foreign-objects bindings
  (unwind-protect form
    cleanups
))

Firstly, the with-dynamic-foreign-objects-with-cleanups form is smaller and faster.

Secondly, if there is an error in any of the cleanups with-dynamic-foreign-objects will cause a memory leak, but this will not happen when using with-dynamic-foreign-objects-with-cleanups .

See also

with-dynamic-foreign-objects


LispWorks Foreign Language Interface User Guide and Reference Manual - 14 Mar 2008

NextPrevUpTopContentsIndex