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