[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] igraph_neighborhood and igraph_free
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] igraph_neighborhood and igraph_free |
Date: |
Fri, 13 Nov 2009 10:26:32 +0000 |
User-agent: |
Mutt/1.5.17 (2007-11-01) |
Hi Peter,
> Basically, the vectors pointed to by the vector filled by
> igraph_neighbourhood need to be passed to igraph_free, but igraph_free
> isn't part of the API (and is only mentioned once in the manual for a
> different function).
igraph_free(ptr) is essentially equivalent to the following code
snippet:
free(ptr);
ptr = NULL;
This prevents one from dereferencing a pointer later to a memory area
that has been freed already. So, you are safe to use free(ptr) on the
vectors pointed to by the vector_ptr filled by igraph_neighborhood.
Also, there is igraph_vector_ptr_free_all(v), which calls igraph_free on
all elements of the vector_ptr -- it seems that this function was
accidentally left out of the reference manual, but it is exposed in the
header file, so feel free to use it. There's also
igraph_vector_ptr_destroy_all(v), which is equivalent to
igraph_vector_ptr_free_all(v) followed by igraph_vector_ptr_destroy(v).
--
Tamas