File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -1797,9 +1797,13 @@ useAsCString (BS fp l) action =
17971797 pokeByteOff buf l (0 :: Word8 )
17981798 action (castPtr buf)
17991799
1800- -- | /O(n) construction/ Use a @ByteString@ with a function requiring a @ CStringLen@ .
1801- -- As for @ useAsCString@ this function makes a copy of the original @ByteString@.
1800+ -- | /O(n) construction/ Use a @ByteString@ with a function requiring a ' CStringLen' .
1801+ -- As for ' useAsCString' this function makes a copy of the original @ByteString@.
18021802-- It must not be stored or used after the subcomputation finishes.
1803+ --
1804+ -- Beware that this function is not required to add a terminating @\NUL@ byte at the end of the 'CStringLen' it provides.
1805+ -- If you need to construct a pointer to a null-terminated sequence, use 'useAsCString'
1806+ -- (and measure length independently if desired).
18031807useAsCStringLen :: ByteString -> (CStringLen -> IO a ) -> IO a
18041808useAsCStringLen p@ (BS _ l) f = useAsCString p $ \ cstr -> f (cstr,l)
18051809
Original file line number Diff line number Diff line change @@ -1758,10 +1758,14 @@ useAsCString sbs action =
17581758 action buf
17591759 where l = length sbs
17601760
1761- -- | /O(n) construction./ Use a @ShortByteString@ with a function requiring a @ CStringLen@ .
1762- -- As for @ useAsCString@ this function makes a copy of the original @ShortByteString@.
1761+ -- | /O(n) construction./ Use a @ShortByteString@ with a function requiring a ' CStringLen' .
1762+ -- As for ' useAsCString' this function makes a copy of the original @ShortByteString@.
17631763-- It must not be stored or used after the subcomputation finishes.
17641764--
1765+ -- Beware that this function does not add a terminating @\NUL@ byte at the end of 'CStringLen'.
1766+ -- If you need to construct a pointer to a null-terminated sequence, use 'useAsCString'
1767+ -- (and measure length independently if desired).
1768+ --
17651769-- @since 0.10.10.0
17661770useAsCStringLen :: ShortByteString -> (CStringLen -> IO a ) -> IO a
17671771useAsCStringLen sbs action =
You can’t perform that action at this time.
0 commit comments