Skip to content
Snippets Groups Projects
Commit c7252f6e authored by Viacheslav Ostroukh's avatar Viacheslav Ostroukh Committed by Christoph Groth
Browse files

fix use of realloc() for array.array

    Fixes issue #74
parent 5c57ed4d
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -13,9 +13,10 @@ __all__ = ['make_undirected', 'remove_duplicates', 'induced_subgraph',
import numpy as np
cimport numpy as np
from libc.stdlib cimport malloc, realloc, free
from libc.string cimport memset
cimport cython
from cpython cimport array
import array
from .defs cimport gint
from .defs import gint_dtype
from .core cimport CGraph, CGraph_malloc
......@@ -176,7 +177,8 @@ def remove_duplicates(CGraph gr, np.ndarray[gint, ndim=1] edge_weights=None):
gr.num_edges = nnz
# Release memory that is not needed any more.
gr.heads = <gint *>realloc(gr.heads, nnz * sizeof(gint))
array.resize(gr._heads, nnz)
gr.heads = <gint *>gr._heads.data.as_ints
if not gr.heads:
raise MemoryError
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment