copyCString* should be in IO. Spotted by Tomasz Zielonka
authorDon Stewart <dons@cse.unsw.edu.au>
Thu, 18 May 2006 01:21:54 +0000 (01:21 +0000)
committerDon Stewart <dons@cse.unsw.edu.au>
Thu, 18 May 2006 01:21:54 +0000 (01:21 +0000)
Data/ByteString.hs

index 06ace6b..139609c 100644 (file)
@@ -1699,12 +1699,12 @@ copy (PS x s l) = create l $ \p -> withForeignPtr x $ \f ->
 
 -- | /O(n)/ Duplicate a CString as a ByteString. Useful if you know the
 -- CString is going to be deallocated from C land.
-copyCString :: CString -> ByteString
+copyCString :: CString -> IO ByteString
 copyCString cstr = copyCStringLen (cstr, (fromIntegral $ c_strlen cstr))
 
 -- | /O(n)/ Same as copyCString, but saves a strlen call when the length is known.
-copyCStringLen :: CStringLen -> ByteString
-copyCStringLen (cstr, len) = inlinePerformIO $ do
+copyCStringLen :: CStringLen -> IO ByteString
+copyCStringLen (cstr, len) = do
     fp <- mallocForeignPtrArray (len+1)
     withForeignPtr fp $ \p -> do
         memcpy p (castPtr cstr) (fromIntegral len)