X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=Mate%2FGarbageAlloc.hs;h=56bb8f17a80cde7cfa65808258fdecaa74a907be;hb=13cf9f65321881050edb99776f29eea8580ec457;hp=f5b109385d14139761a6debfb19b6f0824664ae1;hpb=6f979304b8c4334737feeb5dd5e053c03a8a559c;p=mate.git diff --git a/Mate/GarbageAlloc.hs b/Mate/GarbageAlloc.hs index f5b1093..56bb8f1 100644 --- a/Mate/GarbageAlloc.hs +++ b/Mate/GarbageAlloc.hs @@ -1,19 +1,32 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE CPP #-} +#include "debug.h" module Mate.GarbageAlloc where import Foreign import Foreign.C +#ifdef DEBUG +import Text.Printf +#endif +import Mate.Debug + -- unified place for allocating Memory -- TODO: implement GC stuff ;-) mallocClassData :: Int -> IO (Ptr a) -mallocClassData = mallocBytes +mallocClassData size = do + printfStr "mallocClassData: %d\n" size + mallocBytes size mallocString :: Int -> IO (Ptr a) -mallocString = mallocBytes +mallocString size = do + printfStr "mallocString: %d\n" size + mallocBytes size -foreign export ccall mallocObject :: Int -> IO CUInt -mallocObject :: Int -> IO CUInt +foreign export ccall mallocObject :: Int -> IO CPtrdiff +mallocObject :: Int -> IO CPtrdiff mallocObject size = do ptr <- mallocBytes size + printfStr "mallocObject: %d\n" size return $ fromIntegral $ ptrToIntPtr ptr