[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] vector of igraph_vector_t vectors
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] vector of igraph_vector_t vectors |
Date: |
Wed, 14 Apr 2010 08:35:59 +0100 |
> Could you give me an example how I can make vector of 100 igraph_vector_t
> objects and how I should handle memory
> thank you.
Well, if you only need 100 vectors (in other words, if the number of
igraph_vector_t objects you need is fixed), you don't really need an
igraph_vector_ptr_t for that, you can simply allocate 100 igraph_vector_t
objects using calloc:
igraph_vector_t* vectors;
vectors = (igraph_vector_t*)calloc(100, sizeof(igraph_vector_t));
for (i = 0; i < 100; i++) {
igraph_vector_init(vectors + i);
}
[...do whatever you want with your vectors...]
for (i = 0; i < 100; i++) {
igraph_vector_destroy(vectors + i);
}
free(vectors);
Code untested, but shows the general idea.
--
Tamas