r9575: fix WITH-FOREIGN-OBJECT macro for cmu
[uffi.git] / src / objects.lisp
index 9de66f9767a4c3495e6eeef54910a0180fdc2d8c..57611321ff93a71458ce00d1db6a5ed621063a45 100644 (file)
@@ -166,10 +166,15 @@ an array of TYPE with size SIZE. The TYPE parameter is evaluated."
         (progn ,@body)
       (free-foreign-object ,var)))
   #+(or cmu scl)
-  (let ((obj (gensym)))
-    `(alien:with-alien ((,obj ,(convert-from-uffi-type (eval type) :allocate)))
-       (let ((,var (alien:addr ,obj)))
-        ,@body)))
+  (let ((obj (gensym))
+       (ctype (convert-from-uffi-type (eval type) :allocate)))
+    (if (and (consp ctype) (eq 'array (car ctype)))
+       `(alien:with-alien ((,obj ,ctype))
+         (let* ((,var ,obj))
+           ,@body))
+       `(alien:with-alien ((,obj ,ctype))
+         (let* ((,var (alien:addr ,obj)))
+           ,@body))))
   #+sbcl
   (let ((obj (gensym))
        (ctype (convert-from-uffi-type (eval type) :allocate)))