Commit e363c98b authored by simonm's avatar simonm
Browse files

[project @ 1998-10-06 14:36:27 by simonm]

back out revision 1.2 (change made on wrong branch).
parent b7cf40bb
......@@ -54,7 +54,10 @@ module CString
import PrelPack
import GlaExts
import Addr
import PrelIOBase ( IO(..) )
import PrelIOBase ( IO(..), IOResult(..))
import PrelArr ( StateAndMutableByteArray#(..),
StateAndByteArray#(..)
)
\end{code}
......@@ -161,21 +164,21 @@ out the bounds - use with care.
allocChars :: Int -> IO (MutableByteArray RealWorld Int)
allocChars (I# size#) = IO $ \ s# ->
case newCharArray# size# s# of
(# s2#, barr# #) ->
(# s2#, (MutableByteArray (I# 1#, I# size#) barr#) #)
StateAndMutableByteArray# s2# barr# ->
IOok s2# (MutableByteArray (I# 1#, I# size#) barr#)
allocWords :: Int -> IO (MutableByteArray RealWorld Int)
allocWords (I# size#) = IO $ \ s# ->
case newIntArray# size# s# of
(# s2#, barr# #) ->
(# s2#, (MutableByteArray (I# 1#, I# size#) barr#) #)
StateAndMutableByteArray# s2# barr# ->
IOok s2# (MutableByteArray (I# 1#, I# size#) barr#)
-- Freeze these index-free mutable arrays
freeze :: MutableByteArray RealWorld Int -> IO (ByteArray Int)
freeze (MutableByteArray ixs arr#) = IO $ \ s# ->
case unsafeFreezeByteArray# arr# s# of
(# s2#, frozen# #) ->
(# s2#, (ByteArray ixs frozen#) #)
StateAndByteArray# s2# frozen# ->
IOok s2# (ByteArray ixs frozen#)
-- Copy a null-terminated string from outside the heap to
-- Haskellized nonsense inside the heap
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment