Package: cffi

Function mem-ref

Lambda List

mem-ref (ptr type &optional offset)

Arguments

ptr -- A pointer.
type -- A foreign type.
offset -- An integer (in byte units).

Return Value

The value ptr points to.

Details

Examples

  CFFI> (with-foreign-string (ptr "Saluton")
          (setf (mem-ref ptr :char 3) (char-code #a))
          (loop for i from 0 below 8
                collect (code-char (mem-ref ptr :char i))))
  => (#S #a #l #a #t #o #n #Null)
  CFFI> (setq ptr-to-int (foreign-alloc :int))
  => #<A Mac Pointer #x1047D0>
  CFFI> (mem-ref ptr-to-int :int)
  => 1054619
  CFFI> (setf (mem-ref ptr-to-int :int) 1984)
  => 1984
  CFFI> (mem-ref ptr-to-int :int)
  => 1984  
 

See also