debug: malloc stuff
authorBernhard Urban <lewurm@gmail.com>
Sun, 20 May 2012 10:21:57 +0000 (12:21 +0200)
committerBernhard Urban <lewurm@gmail.com>
Sun, 20 May 2012 19:37:12 +0000 (21:37 +0200)
Mate/GarbageAlloc.hs

index b0165d0b9453a3eef149ab1b2213659060e2a2ab..1a272fbaedbbd02265d47a3a72785ab5b755cd8e 100644 (file)
@@ -1,20 +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
 mallocObject size = do
   ptr <- mallocBytes size
+  printfStr "mallocObject: %d\n" size
   return $ fromIntegral $ ptrToIntPtr ptr