Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
jberryman
GHC
Commits
e363c98b
Commit
e363c98b
authored
Oct 06, 1998
by
simonm
Browse files
[project @ 1998-10-06 14:36:27 by simonm]
back out revision 1.2 (change made on wrong branch).
parent
b7cf40bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
ghc/lib/misc/CString.lhs
View file @
e363c98b
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment