{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE CPP #-}
-#include "debug.h"
module Mate.GarbageAlloc(
mallocClassData,
mallocStringGC,
import Mate.GC.Boehm
---import Text.Printf
import Mate.Debug
-- unified place for allocating Memory
mallocClassData :: Int -> IO (Ptr a)
mallocClassData size = do
- printfStr "mallocClassData: %d\n" size
+ printfStr $ printf "mallocClassData: %d\n" size
mem <- mallocBytes size
addRootGC mem (plusPtr mem size)
return mem
mallocStringGC :: Int -> IO (Ptr a)
mallocStringGC size = do
- printfStr "mallocString: %d\n" size
+ printfStr $ printf "mallocString: %d\n" size
mallocBytesGC size
foreign export ccall mallocObjectGC :: Int -> IO CPtrdiff
mallocObjectGC :: Int -> IO CPtrdiff
mallocObjectGC size = do
ptr <- mallocBytesGC size
- printfStr "mallocObject: %d\n" size
+ printfStr $ printf "mallocObject: %d\n" size
return $ fromIntegral $ ptrToIntPtr ptr
mallocObjectUnmanaged :: Int -> IO CPtrdiff
mallocObjectUnmanaged size = do
ptr <- mallocBytes size
- printfStr "mallocObjectUnmanged: %d\n" size
+ printfStr $ printf "mallocObjectUnmanged: %d\n" size
return $ fromIntegral $ ptrToIntPtr ptr
mallocStringUnmanaged :: Int -> IO (Ptr a)
mallocStringUnmanaged size = do
- printfStr "mallocStringUnamaged: %d\n" size
+ printfStr $ printf "mallocStringUnamaged: %d\n" size
mallocBytes size