RosettaCodeData/Task/Memory-allocation/Haskell/memory-allocation-1.hs

10 lines
272 B
Haskell
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
import Foreign
bytealloc :: IO ()
bytealloc = do
a0 <- mallocBytes 100 -- Allocate 100 bytes
free a0 -- Free them again
allocaBytes 100 $ \a -> -- Allocate 100 bytes; automatically
-- freed when closure finishes
poke (a::Ptr Word32) 0