Skip to content

Commit

Permalink
Document that useAsCStringLen does not append NUL
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Sep 16, 2023
1 parent 367f6bf commit 9721aa6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions System/OsPath/Data/ByteString/Short/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,14 @@ useAsCString bs action =
action buf
where l = length bs

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

0 comments on commit 9721aa6

Please sign in to comment.