Dear all,

  I try to use the following to convert [[Int]] to C's int[][] :

foreign export stdcall doCompForeign :: CString -> CString -> IO (Ptr (Ptr Int))


doCompForeign :: CString -> CString -> IO (Ptr (Ptr Int))
doCompForeign patraw cnameraw =         let     pat = peekCString patraw 
                                                cname = peekCString cnameraw
                                        in doCompHelp pat cname 
     

doCompHelp :: IO String-> IO String -> IO (Ptr (Ptr Int))
doCompHelp patIO cnameIO = do   pat <- patIO
                                cname <- cnameIO
                                if pat Prelude.== "hns" then (doComp hns cname)
                                        else if pat Prelude.== "up" then 
(doComp up cname)
                                        else if pat Prelude.== "down" then 
(doComp down cname)
                                        else if pat Prelude.== "hill" then 
(doComp hill cname)
                                        else (doComp hs cname)

doComp :: Pattern -> String ->  IO (Ptr (Ptr Int))
doComp pat cname
 = do (tiPrim,b) <- loadTi cname
      t1 <- getCPUTime             
      let insts = runVMC (solve (1,b) pat) tiPrim 
      newArray (toArray insts)

toArray :: [[Int]] ->  [(Ptr Int)]
toArray lst =   toResultant
                where toResultant = [toArrayRec (lst!!1)] Prelude.++ toArray 
(tail lst)
                 
toArrayRec :: [Int] -> Ptr Int
toArrayRec lst = unsafePerformIO (newArray lst)

However, it can compile without problem, however I receive the
following error when I run it from C code :

Heap exhausted;
Current maximum heap size is 268435456 bytes (256 Mb);
use `+RTS -M<size>' to increase it.

What have I done wrong ? Some help please.

Thank you in advance for your help and attention.

Best Regards,

David Lo
_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to