From ce31c7edc5c3f34464b0dacff7de7e412e3dc6f2 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Wed, 13 Dec 2023 14:13:55 +0100 Subject: chore: free allocated memory in comments --- app/Comment.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/Comment.hs b/app/Comment.hs index c834509..7bd4ad5 100644 --- a/app/Comment.hs +++ b/app/Comment.hs @@ -24,7 +24,7 @@ import Data.Text qualified as T import Data.Text.Encoding qualified as T import Exception qualified as E import Foreign.C.String -import Foreign.Marshal.Alloc (malloc) +import Foreign.Marshal.Alloc (free, malloc) import Foreign.Marshal.Array (mallocArray, peekArray) import Foreign.Ptr (nullPtr) import Foreign.Storable @@ -137,7 +137,10 @@ childNodesFromNode n = do tsNode <- malloc poke tsNode (S.nodeTSNode n) S.ts_node_copy_child_nodes tsNode ns - peekArray numChildren ns + free tsNode + ns' <- peekArray numChildren ns + free ns + pure ns' data CommentStyle = LineStyle T.Text -- cgit v1.2.3