diff options
author | defanor <defanor@uberspace.net> | 2018-04-29 13:09:40 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2018-04-29 13:09:40 +0300 |
commit | c74a06e761c3a4616a92fd4d3ad0ac9edb97e06c (patch) | |
tree | 945ed71395959dd70589f1f291d6a82dc735287a /Redland/Util.hs | |
parent | f9d699facc2a48022d44a67b6ef8eb76a6ca1233 (diff) |
So that it's easier to use it safely: apparently the recently found
segfault was caused by improper order of freeing the resources, while
withNew/withNewMaybe help to ensure the correct order.
Diffstat (limited to 'Redland/Util.hs')
-rw-r--r-- | Redland/Util.hs | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/Redland/Util.hs b/Redland/Util.hs index c7862be..0c294ab 100644 --- a/Redland/Util.hs +++ b/Redland/Util.hs @@ -181,17 +181,9 @@ statementToTriple statement = do pure $ Triple s p o where componentToTriple :: (ForeignPtr RedlandStatement -> - IO (Maybe (ForeignPtr RedlandNode))) + InitializerMaybe RedlandNode) -> IO (Maybe Node) - componentToTriple f = do - c <- f statement - case c of - Just c' -> do - n <- redlandNodeToNode c' - -- segfaulting without finalization here, not sure why. - finalizeForeignPtr c' - pure $ Just n - Nothing -> pure Nothing + componentToTriple f = withNewMaybe (f statement) redlandNodeToNode -- | A conversion function. tripleToStatement :: ForeignPtr RedlandWorld |