gc: delegated mallocs in GarbageAlloc to hs-boehmgc (Mate.GC.Boehm.mallocBytes);
[mate.git] / Mate / GarbageAlloc.hs
index e7c1cc955a266ab09fb3691945fb8aadd1d5272d..d993f93e68f2af865c3ee841e51fb0cfe21fe363 100644 (file)
@@ -1,11 +1,17 @@
 {-# LANGUAGE ForeignFunctionInterface #-}
 {-# LANGUAGE CPP #-}
 #include "debug.h"
-module Mate.GarbageAlloc where
+module Mate.GarbageAlloc(
+    mallocClassData,
+    mallocString,
+    mallocObject,
+    getHeapMemory)  where
 
 import Foreign
 import Foreign.C
 
+import Mate.GC.Boehm
+
 import Text.Printf
 import Mate.Debug
 
@@ -15,17 +21,17 @@ import Mate.Debug
 mallocClassData :: Int -> IO (Ptr a)
 mallocClassData size = do
   printfStr "mallocClassData: %d\n" size
-  mallocBytes size
+  mallocBytesGC size
 
 mallocString :: Int -> IO (Ptr a)
 mallocString size = do
   printfStr "mallocString: %d\n" size
-  mallocBytes size
+  mallocBytesGC size
 
 foreign export ccall mallocObject :: Int -> IO CPtrdiff
 mallocObject :: Int -> IO CPtrdiff
 mallocObject size = do
-  ptr <- mallocBytes size
+  ptr <- mallocBytesGC size
   printfStr "mallocObject: %d\n" size
   return $ fromIntegral $ ptrToIntPtr ptr
 
@@ -35,3 +41,7 @@ demoInterfaceCall :: CUInt -> IO ()
 demoInterfaceCall val = do
   printf "demoInterfaceCall: 0x%08x\n" (fromIntegral val :: Word32)
   return ()
+
+getHeapMemory :: IO Int
+getHeapMemory = getHeapSize
+