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 ...@@ -54,7 +54,10 @@ module CString
import PrelPack import PrelPack
import GlaExts import GlaExts
import Addr import Addr
import PrelIOBase ( IO(..) ) import PrelIOBase ( IO(..), IOResult(..))
import PrelArr ( StateAndMutableByteArray#(..),
StateAndByteArray#(..)
)
\end{code} \end{code}
...@@ -161,21 +164,21 @@ out the bounds - use with care. ...@@ -161,21 +164,21 @@ out the bounds - use with care.
allocChars :: Int -> IO (MutableByteArray RealWorld Int) allocChars :: Int -> IO (MutableByteArray RealWorld Int)
allocChars (I# size#) = IO $ \ s# -> allocChars (I# size#) = IO $ \ s# ->
case newCharArray# size# s# of case newCharArray# size# s# of
(# s2#, barr# #) -> StateAndMutableByteArray# s2# barr# ->
(# s2#, (MutableByteArray (I# 1#, I# size#) barr#) #) IOok s2# (MutableByteArray (I# 1#, I# size#) barr#)
allocWords :: Int -> IO (MutableByteArray RealWorld Int) allocWords :: Int -> IO (MutableByteArray RealWorld Int)
allocWords (I# size#) = IO $ \ s# -> allocWords (I# size#) = IO $ \ s# ->
case newIntArray# size# s# of case newIntArray# size# s# of
(# s2#, barr# #) -> StateAndMutableByteArray# s2# barr# ->
(# s2#, (MutableByteArray (I# 1#, I# size#) barr#) #) IOok s2# (MutableByteArray (I# 1#, I# size#) barr#)
-- Freeze these index-free mutable arrays -- Freeze these index-free mutable arrays
freeze :: MutableByteArray RealWorld Int -> IO (ByteArray Int) freeze :: MutableByteArray RealWorld Int -> IO (ByteArray Int)
freeze (MutableByteArray ixs arr#) = IO $ \ s# -> freeze (MutableByteArray ixs arr#) = IO $ \ s# ->
case unsafeFreezeByteArray# arr# s# of case unsafeFreezeByteArray# arr# s# of
(# s2#, frozen# #) -> StateAndByteArray# s2# frozen# ->
(# s2#, (ByteArray ixs frozen#) #) IOok s2# (ByteArray ixs frozen#)
-- Copy a null-terminated string from outside the heap to -- Copy a null-terminated string from outside the heap to
-- Haskellized nonsense inside the heap -- 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