Next: , Previous: mem-aref, Up: Pointers


mem-ref

Syntax

— Accessor: mem-ref ptr type &optional offset ⇒ object

Arguments and Values

ptr
A pointer.
type
A foreign type.
offset
An integer (in byte units).
object
The value ptr points to.

Description

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

mem-aref