+(defun clear-memory (from length)
+ #+cmu(vm::system-area-fill 0 from 0 (* 8 length))
+ #+sbcl(system-area-ub8-fill 0 from 0 length))
+
+(defmacro with-allocated-memory ((var size) &body body)
+ (if (constantp size)
+ (let ((alien (make-symbol "ALIEN"))
+ (size (eval size)))
+ `(with-alien ((,alien (array #+sbcl(sb-alien:unsigned 8) #+cmu(alien:unsigned 8) ,size)))
+ (let ((,var (alien-sap ,alien)))
+ (clear-memory ,var ,size)
+ ,@body)))
+ `(let ((,var (allocate-memory ,size)))
+ (unwind-protect
+ (progn ,@body)
+ (deallocate-memory ,var)))))
+