RosettaCodeData/Task/Memory-allocation/Haskell/memory-allocation-1.hs
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

9 lines
272 B
Haskell

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