Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-igraph
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-igraph
Commits
70148846
Commit
70148846
authored
Apr 22, 2018
by
Kai Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix memory leak
parent
2183f77c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
11 deletions
+18
-11
haskell_igraph.c
cbits/haskell_igraph.c
+0
-5
haskell_igraph.h
include/haskell_igraph.h
+0
-2
Data.chs
src/IGraph/Internal/Data.chs
+16
-4
Graph.chs
src/IGraph/Internal/Graph.chs
+2
-0
No files found.
cbits/haskell_igraph.c
View file @
70148846
#include <igraph/igraph.h>
#include "haskell_attributes.h"
void
my_igraph_vector_destroy
(
igraph_vector_t
*
v
)
{
printf
(
"free vector
\n
"
);
igraph_vector_destroy
(
v
);
}
const
igraph_attribute_table_t
igraph_haskell_attribute_table
=
{
&
igraph_haskell_attribute_init
,
&
igraph_haskell_attribute_destroy
,
&
igraph_haskell_attribute_copy
,
&
igraph_haskell_attribute_add_vertices
,
...
...
include/haskell_igraph.h
View file @
70148846
...
...
@@ -5,6 +5,4 @@
void
haskelligraph_init
();
void
my_igraph_vector_destroy
(
igraph_vector_t
*
v
);
#endif
src/IGraph/Internal/Data.chs
View file @
70148846
...
...
@@ -68,7 +68,7 @@ import Data.List.Split (chunksOf)
--------------------------------------------------------------------------------
{#pointer *igraph_vector_t as Vector foreign finalizer
my_
igraph_vector_destroy newtype#}
igraph_vector_destroy newtype#}
-- Construtors and destructors
...
...
@@ -78,7 +78,7 @@ allocaVector f = mallocBytes {# sizeof igraph_vector_t #} >>= f
addVectorFinalizer :: Ptr Vector -> IO Vector
addVectorFinalizer ptr = do
vec <- newForeignPtr
my_
igraph_vector_destroy ptr
vec <- newForeignPtr igraph_vector_destroy ptr
return $ Vector vec
{-# INLINE addVectorFinalizer #-}
...
...
@@ -128,9 +128,21 @@ toList vec = do
{#pointer *igraph_vector_ptr_t as VectorPtr foreign finalizer
igraph_vector_ptr_destroy
_all
newtype#}
igraph_vector_ptr_destroy newtype#}
{#fun igraph_vector_ptr_init as igraphVectorPtrNew { +, `Int' } -> `VectorPtr' #}
allocaVectorPtr :: (Ptr VectorPtr -> IO a) -> IO a
allocaVectorPtr f = mallocBytes {# sizeof igraph_vector_ptr_t #} >>= f
{-# INLINE allocaVectorPtr #-}
addVectorPtrFinalizer :: Ptr VectorPtr -> IO VectorPtr
addVectorPtrFinalizer ptr = do
vec <- newForeignPtr igraph_vector_ptr_destroy ptr
return $ VectorPtr vec
{-# INLINE addVectorPtrFinalizer #-}
{#fun igraph_vector_ptr_init as igraphVectorPtrNew
{ allocaVectorPtr- `VectorPtr' addVectorPtrFinalizer*
, `Int' } -> `CInt' void- #}
{#fun igraph_vector_ptr_e as ^ { `VectorPtr', `Int' } -> `Ptr ()' #}
{#fun igraph_vector_ptr_set as ^ { `VectorPtr', `Int', id `Ptr ()' } -> `()' #}
...
...
src/IGraph/Internal/Graph.chs
View file @
70148846
...
...
@@ -21,11 +21,13 @@ import IGraph.Internal.C2HS
allocaIGraph :: (Ptr IGraph -> IO a) -> IO a
allocaIGraph f = mallocBytes {# sizeof igraph_t #} >>= f
{-# INLINE allocaIGraph #-}
addIGraphFinalizer :: Ptr IGraph -> IO IGraph
addIGraphFinalizer ptr = do
vec <- newForeignPtr igraph_destroy ptr
return $ IGraph vec
{-# INLINE addIGraphFinalizer #-}
{#fun igraph_empty as igraphNew'
{ allocaIGraph- `IGraph' addIGraphFinalizer*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment