From f0ddf0fe728ce147e8a54b3fa76ba00c50048a27 Mon Sep 17 00:00:00 2001 From: inari Date: Wed, 29 Jan 2014 16:02:07 +0000 Subject: changes to pools in haskell bindings --- src/runtime/haskell-bind/Gu.hsc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/runtime/haskell-bind/Gu.hsc') diff --git a/src/runtime/haskell-bind/Gu.hsc b/src/runtime/haskell-bind/Gu.hsc index e9d060c92..20a728c79 100644 --- a/src/runtime/haskell-bind/Gu.hsc +++ b/src/runtime/haskell-bind/Gu.hsc @@ -9,6 +9,7 @@ import Foreign import Foreign.C import Foreign.C.String import Foreign.Ptr +import Control.Exception data GuEnum @@ -117,6 +118,10 @@ ptrToList appl arity = do let ptr = appl `plusPtr` (#offset PgfApplication, args) --args is not an argument, it's the actual field name sequence [peek (ptr `plusPtr` (i * (#size PgfExpr))) | i<-[0..arity-1]] - - +withGuPool :: (Ptr GuPool -> IO a) -> IO a +withGuPool f = do + pl <- gu_new_pool + f pl `finally` gu_pool_free pl + -- for true haskell persons + -- withGuPool f = bracket gu_new_pool gu_pool_free f -- cgit v1.2.3