uffi/doc ref.sgml,1.33,1.34

"Kevin M. Rosenberg" <[email protected]> Mon, 5 May 2003 15:57:52 -0600
Newsgroups gmane.lisp.uffi.cvs
Message-ID <[email protected]>
Update of /pubcvs/uffi/doc
In directory boa.b9.com:/tmp/cvs-serv20855/doc

Modified Files:
	ref.sgml 
Log Message:
Auto commit for Debian build

Index: ref.sgml
===================================================================
RCS file: /pubcvs/uffi/doc/ref.sgml,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** ref.sgml	23 Nov 2002 18:03:30 -0000	1.33
--- ref.sgml	5 May 2003 21:57:50 -0000	1.34
***************
*** 1544,1547 ****
--- 1544,1566 ----
  </programlisting>
  
+ <para>  Foreign functions that return pointers to freshly allocated
+ strings should in general not return cstrings, but foreign strings.
+ (There is no portable way to release such cstrings from Lisp.)  The
+ following is an example of handling such a function.  </para>
+ 
+ <programlisting>
+ (uffi:def-function ("readline" c-readline)
+     ((prompt :cstring))
+   :returning (* :char))
+ 
+ (defun readline (prompt)
+   "Reads a string from console with line-editing."
+   (with-cstring (c-prompt prompt)
+       (let* ((c-str (c-readline c-prompt))
+              (str (convert-from-foreign-string c-str)))
+         (uffi:free-foreign-object c-str)
+         str)))
+ </programlisting>
+ 
  </partintro>