Skip to content

Commit

Permalink
Document the behaviour of unsafeUseAsCStringLen when BS.empty is pass…
Browse files Browse the repository at this point in the history
…ed (fixes #207)
  • Loading branch information
fumieval committed Jul 4, 2020
1 parent f18af8e commit 136344f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Data/ByteString/Unsafe.hs
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,6 @@ unsafeUseAsCString (PS ps s _) ac = withForeignPtr ps $ \p -> ac (castPtr p `plu
-- will break referential transparency. To avoid this, use
-- 'useAsCStringLen', which makes a copy of the original 'ByteString'.
--
-- If 'empty' is given, It will pass ('nullPtr', 0).
unsafeUseAsCStringLen :: ByteString -> (CStringLen -> IO a) -> IO a
unsafeUseAsCStringLen (PS ps s l) f = withForeignPtr ps $ \p -> f (castPtr p `plusPtr` s,l)

0 comments on commit 136344f

Please sign in to comment.