— Wraps the allocation of a foreign object around a body of code.
The variable name to bind.
The type of foreign object to allocate. This parameter is evaluated.
The result of evaluating the
This function wraps the allocation, binding, and destruction of a foreign object. On CMUCL and Lispworks platforms the object is stack allocated for efficiency. Benchmarks show that AllegroCL performs much better with static allocation.
(defun gethostname2 () "Returns the hostname" (uffi:with-foreign-object (name '(:array :unsigned-char 256)) (if (zerop (c-gethostname (uffi:char-array-to-pointer name) 256)) (uffi:convert-from-foreign-string name) (error "gethostname() failed."))))