gc: factor out allocation
[mate.git] / Mate / GarbageAlloc.hs
1 module Mate.GarbageAlloc where
2
3 import Foreign
4 import Foreign.C
5
6 -- unified place for allocating Memory
7 -- TODO: implement GC stuff ;-)
8
9 mallocClassData :: Int -> IO (Ptr a)
10 mallocClassData = mallocBytes
11
12 mallocString :: Int -> IO (Ptr a)
13 mallocString = mallocBytes
14
15 foreign export ccall mallocObject :: Int -> IO CUInt
16 mallocObject :: Int -> IO CUInt
17 mallocObject size = do
18   ptr <- mallocBytes size
19   return $ fromIntegral $ ptrToIntPtr ptr