X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ftarget-c-call.lisp;h=32924533ca081208422c870d988bd4064a1fef9d;hb=15d6e7c9a2c3234f95dfe278046fa2fee1b0c007;hp=d9575b847eeb9d38bd46a308799f0ffc97b75968;hpb=6139c89c89f45c03509e4f3156293ff656716a8c;p=sbcl.git diff --git a/src/code/target-c-call.lisp b/src/code/target-c-call.lisp index d9575b8..3292453 100644 --- a/src/code/target-c-call.lisp +++ b/src/code/target-c-call.lisp @@ -37,11 +37,14 @@ (defun %naturalize-c-string (sap) (declare (type system-area-pointer sap)) - (with-alien ((ptr (* char) sap)) - (let* ((length (alien-funcall (extern-alien "strlen" - (function integer (* char))) - ptr)) - (result (make-string length))) + (locally (declare (optimize (speed 3) (safety 0))) - (sb!kernel:%byte-blt sap 0 result 0 length) - result))) + (let ((length (loop for offset of-type fixnum upfrom 0 + until (zerop (sap-ref-8 sap offset)) + finally (return offset)))) + (let ((result (make-string length :element-type 'base-char))) + (sb!kernel:copy-from-system-area sap 0 + result (* sb!vm:vector-data-offset + sb!vm:n-word-bits) + (* length sb!vm:n-byte-bits)) + result))))