Next: , Up: Strings


foreign-string-alloc

Syntax

— Function: foreign-string-alloc string-or-ub8-array => pointer

Arguments and Values

string-or-ub8-array
A Lisp string or a Lisp array with element-type (unsigned-byte 8).
pointer
A pointer to the newly allocated foreign string.

Description

The foreign-string-alloc function allocates a foreign string containing a Lisp string or (unsigned-byte 8) array.

This string must be freed with foreign-string-free.

Examples

  CFFI> (setq str (foreign-string-alloc "Hello, foreign world!"))
  => #<FOREIGN-ADDRESS #x00400560>
  CFFI> (foreign-funcall "strlen" :pointer str :int)
  => 21

See Also

foreign-string-free
with-foreign-string