Skip to content

Commit 9721aa6

Browse files
committed
Document that useAsCStringLen does not append NUL
1 parent 367f6bf commit 9721aa6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

System/OsPath/Data/ByteString/Short/Internal.hs

+6-2
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,14 @@ useAsCString bs action =
164164
action buf
165165
where l = length bs
166166

167-
-- | /O(n) construction./ Use a @ShortByteString@ with a function requiring a @CStringLen@.
168-
-- As for @useAsCString@ this function makes a copy of the original @ShortByteString@.
167+
-- | /O(n) construction./ Use a @ShortByteString@ with a function requiring a 'CStringLen'.
168+
-- As for 'useAsCString' this function makes a copy of the original @ShortByteString@.
169169
-- It must not be stored or used after the subcomputation finishes.
170170
--
171+
-- Beware that this function does not add a terminating @\NUL@ byte at the end of 'CStringLen'.
172+
-- If you need to construct a pointer to a null-terminated sequence, use 'useAsCString'
173+
-- (and measure length independently if desired).
174+
--
171175
-- @since 0.10.10.0
172176
useAsCStringLen :: ShortByteString -> (CStringLen -> IO a) -> IO a
173177
useAsCStringLen bs action =

0 commit comments

Comments
 (0)