Next: , Previous: foreign-string-free, Up: Strings


foreign-string-to-lisp

Syntax

— Function: foreign-string-to-lisp ptr &optional size null-terminated-p => string

Arguments and Values

ptr
A pointer.
size
The maximum string size. array-total-size-limit, by default.
null-terminated-p
Specifies if the string ptr points to is null terminated. True, by default.

Description

The foreign-string-to-lisp function copies at most size characters from ptr into a Lisp string.

When null-terminated-p is true (the default), characters are copied until size is reached or a NULL character is found.

If ptr is a null pointer, returns nil.

Note that the :string type will automatically convert between Lisp strings and foreign strings.

Examples

  CFFI> (foreign-funcall "getenv" :string "HOME" :pointer)
  => #<FOREIGN-ADDRESS #xBFFFFFD5>
  CFFI> (foreign-string-to-lisp *)
  => "/Users/luis"

See Also

lisp-string-to-foreign
foreign-string-alloc