projects
/
uffi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r8999: add new function FOREIGN-STRING-LENGTH
[uffi.git]
/
src
/
strings.lisp
diff --git
a/src/strings.lisp
b/src/strings.lisp
index e4d67013a80a1db25ac52324fdf0ffe4993542bb..0585d43ada673ff958cd16b92c0edff088343214 100644
(file)
--- a/
src/strings.lisp
+++ b/
src/strings.lisp
@@
-223,6
+223,15
@@
that LW/CMU automatically converts strings from c-calls."
`(new-ptr ,size)
)
`(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))
(defmacro with-foreign-string ((foreign-string lisp-string) &body body)
(let ((result (gensym)))
`(let* ((,foreign-string (convert-to-foreign-string ,lisp-string))