Skip to content
Snippets Groups Projects
Commit 8e2db0e3 authored by sof's avatar sof
Browse files

[project @ 1997-09-03 23:43:49 by sof]

fix: freeze_ps_array did not return ByteArray with valid bounds (was error closure)
parent b5639289
No related merge requests found
...@@ -228,7 +228,7 @@ packNBytesST len@(I# length#) str = ...@@ -228,7 +228,7 @@ packNBytesST len@(I# length#) str =
-- fill in packed string from "str" -- fill in packed string from "str"
fill_in ch_array 0# str >> fill_in ch_array 0# str >>
-- freeze the puppy: -- freeze the puppy:
freeze_ps_array ch_array freeze_ps_array ch_array length#
where where
fill_in :: MutableByteArray s Int -> Int# -> [Char] -> ST s () fill_in :: MutableByteArray s Int -> Int# -> [Char] -> ST s ()
fill_in arr_in# idx [] = fill_in arr_in# idx [] =
...@@ -246,7 +246,7 @@ packNBytesST len@(I# length#) str = ...@@ -246,7 +246,7 @@ packNBytesST len@(I# length#) str =
\begin{code} \begin{code}
new_ps_array :: Int# -> ST s (MutableByteArray s Int) new_ps_array :: Int# -> ST s (MutableByteArray s Int)
write_ps_array :: MutableByteArray s Int -> Int# -> Char# -> ST s () write_ps_array :: MutableByteArray s Int -> Int# -> Char# -> ST s ()
freeze_ps_array :: MutableByteArray s Int -> ST s (ByteArray Int) freeze_ps_array :: MutableByteArray s Int -> Int# -> ST s (ByteArray Int)
new_ps_array size = ST $ \ (S# s) -> new_ps_array size = ST $ \ (S# s) ->
case (newCharArray# size s) of { StateAndMutableByteArray# s2# barr# -> case (newCharArray# size s) of { StateAndMutableByteArray# s2# barr# ->
...@@ -259,9 +259,9 @@ write_ps_array (MutableByteArray _ barr#) n ch = ST $ \ (S# s#) -> ...@@ -259,9 +259,9 @@ write_ps_array (MutableByteArray _ barr#) n ch = ST $ \ (S# s#) ->
((), S# s2#)} ((), S# s2#)}
-- same as unsafeFreezeByteArray -- same as unsafeFreezeByteArray
freeze_ps_array (MutableByteArray ixs arr#) = ST $ \ (S# s#) -> freeze_ps_array (MutableByteArray _ arr#) len# = ST $ \ (S# s#) ->
case unsafeFreezeByteArray# arr# s# of { StateAndByteArray# s2# frozen# -> case unsafeFreezeByteArray# arr# s# of { StateAndByteArray# s2# frozen# ->
(ByteArray ixs frozen#, S# s2#) } (ByteArray (0,I# len#) frozen#, S# s2#) }
\end{code} \end{code}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment