@@ -367,16 +367,16 @@ data State s = State !(ForeignPtr StreamState)
367
367
368
368
mkState :: ST s (State s )
369
369
mkState = unsafeIOToST $ do
370
- ptr <- mallocBytes (# {const sizeof(z_stream)})
371
- # {poke z_stream, msg} ptr nullPtr
372
- # {poke z_stream, zalloc} ptr nullPtr
373
- # {poke z_stream, zfree} ptr nullPtr
374
- # {poke z_stream, opaque} ptr nullPtr
375
- # {poke z_stream, next_in} ptr nullPtr
376
- # {poke z_stream, next_out} ptr nullPtr
377
- # {poke z_stream, avail_in } ptr ( 0 :: CUInt )
378
- # {poke z_stream, avail_out} ptr (0 :: CUInt )
379
- stream <- newForeignPtr_ ptr
370
+ stream <- mallocForeignPtrBytes (# {const sizeof(z_stream)})
371
+ withForeignPtr stream $ \ ptr -> do
372
+ # {poke z_stream, msg} ptr nullPtr
373
+ # {poke z_stream, zalloc} ptr nullPtr
374
+ # {poke z_stream, zfree} ptr nullPtr
375
+ # {poke z_stream, opaque} ptr nullPtr
376
+ # {poke z_stream, next_in} ptr nullPtr
377
+ # {poke z_stream, next_out } ptr nullPtr
378
+ # {poke z_stream, avail_in} ptr (0 :: CUInt )
379
+ # {poke z_stream, avail_out} ptr ( 0 :: CUInt )
380
380
return (State stream nullForeignPtr nullForeignPtr 0 0 )
381
381
382
382
runStream :: Stream a -> State s -> ST s (a , State s )
0 commit comments