anchor.diff:  ;; License along with this library; if not, write to the Free Software
   ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   
  -;; $Id: glib.lisp,v 1.5 2000-08-23 21:36:44 espen Exp $
  +;; $Id: glib.lisp,v 1.6 2000-09-04 22:10:26 espen Exp $
   
   
   (in-package "GLIB")
  
positive.code: 
  (deftype quark () 'unsigned)
  
  (define-foreign %quark-get-reserved () quark)
  
  (defvar *quark-from-object* (make-hash-table))
  (defvar *quark-to-object* (make-hash-table))
  
negative.code: 
  
  
  ;;; Vector
  
  (deftype-method translate-type-spec vector (type-spec)
    (declare (ignore type-spec))
    (translate-type-spec 'pointer))
  
  (deftype-method size-of vector (type-spec)
    (declare (ignore type-spec))
    (size-of 'pointer))
  
  (deftype-method translate-to-alien vector (type-spec vector &optional copy)
    (declare (ignore copy))
    (destructuring-bind (element-type &optional (length '*))
        (cdr (type-expand-to 'vector type-spec))
      (let ((element-to-alien (translate-to-alien element-type 'element :copy))
  	  (element-size (size-of element-type)))
        `(let ((vector ,vector))
  	 (let ((c-vector
  		(allocate-memory
  		 ,(if (eq length '*)
  		      `(* ,element-size (length vector))
  		    (* element-size length)))))
  	   (dotimes (i ,(if (eq length '*) '(length vector) length) c-vector)
  	     (setf
  	      (,(sap-ref-fname element-type) c-vector (* i ,element-size))
  	      ,(translate-to-alien element-type '(svref vector i) :copy))))))))
  
  (deftype-method cleanup-alien vector (type-spec sap &optional copied)
    (declare (ignore type-spec copied))
    ;; The individual elements also have to be cleaned up to avoid memory leaks,
    ;; but this is currently not possible because we can't always tell the
    ;; length of the vector
    `(deallocate-memory ,sap))
  