Name

with-cstring — Binds a newly created cstring.Macro

Syntax

	with-cstring
	(cstring string) {body}
      

Arguments and Values

cstring

A symbol naming the cstring to be created.

string

A Lisp string that will be translated to a cstring.

body

The body of where the cstring will be bound.

Description

Binds a symbol to a cstring created from conversion of a string. Automatically frees the cstring.

Examples

(def-function ("getenv" c-getenv) 
   ((name :cstring))
   :returning :cstring)

(defun getenv (key)
  "Returns an environment variable, or NIL if it does not exist"
  (check-type key string)
  (with-cstring (key-cstring key)
    (convert-from-cstring (c-getenv key-cstring))))
	

Side Effects

None.

Affected by

None.

Exceptional Situations

None.