1 {-# LANGUAGE ForeignFunctionInterface #-}
4 module Mate.GarbageAlloc(
18 -- unified place for allocating Memory
19 -- TODO: implement GC stuff ;-)
21 mallocClassData :: Int -> IO (Ptr a)
22 mallocClassData size = do
23 printfStr "mallocClassData: %d\n" size
26 mallocString :: Int -> IO (Ptr a)
27 mallocString size = do
28 printfStr "mallocString: %d\n" size
31 foreign export ccall mallocObject :: Int -> IO CPtrdiff
32 mallocObject :: Int -> IO CPtrdiff
33 mallocObject size = do
34 ptr <- mallocBytesGC size
35 printfStr "mallocObject: %d\n" size
36 return $ fromIntegral $ ptrToIntPtr ptr
39 foreign export ccall demoInterfaceCall :: CUInt -> IO ()
40 demoInterfaceCall :: CUInt -> IO ()
41 demoInterfaceCall val = do
42 printf "demoInterfaceCall: 0x%08x\n" (fromIntegral val :: Word32)
45 getHeapMemory :: IO Int
46 getHeapMemory = getHeapSize