X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fstrings.lisp;h=0585d43ada673ff958cd16b92c0edff088343214;hb=5ee29e2a72598eb6db2063510b2ea6046945b70c;hp=e4d67013a80a1db25ac52324fdf0ffe4993542bb;hpb=7177cf1ffcd71227b04934ae09188dd708ae3bb9;p=uffi.git diff --git a/src/strings.lisp b/src/strings.lisp index e4d6701..0585d43 100644 --- a/src/strings.lisp +++ b/src/strings.lisp @@ -223,6 +223,15 @@ that LW/CMU automatically converts strings from c-calls." `(new-ptr ,size) ) +(defun foreign-string-length (foreign-string) + #+allegro `(ff:foreign-strlen ,ptr) + #-allegro + `(loop with size = 0 + until (char= (deref-array ,ptr '(:array :unsigned-char) size) #\Null) + do (incf size) + finally return size)) + + (defmacro with-foreign-string ((foreign-string lisp-string) &body body) (let ((result (gensym))) `(let* ((,foreign-string (convert-to-foreign-string ,lisp-string))