Hello everybody.
I'm running a bit short of ideas and an help would be really appreciated. I have looked a bit in previous topics and haven't found anything similar to my problem.
So...here it is:
I have in a header called LightpathDB.h the following structure declared into the class LightpathDB:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
struct cell {
int source;
int destination;
int nr_paths;
int nr_clockwise;
int nr_cntclockwise;
int shortest; /* 1-> clockwise
2-> counterclockwise */
int* connectionMatrix;
LINK_COST* costMatrix;
//vector of vectors of int
std::vector<vector<int>> vVectorFirstFs;
std::vector<vector<int>> vVectorLpId;
void clearMatrix();
};
| |
as you can see, I have two vector of vectors of int: vVectorFirstFs and vVectorLpId.
I have to manage them in a very dynamic way. I don t know at the beginning how many of this structs cell I have to create: I don't know how many elements are in both vectors (if we compare the vector of vectors to a matrix, I don't knwo how many rows and how many columns).
At the beginning of my program, I call this function: (here the code, only the important lines)
1 2 3 4 5 6 7 8 9 10 11 12 13
|
struct LightpathDB::cell** LightpathDB::initializeGrooming(int nodes)
{
struct cell **data=NULL;
data = (struct cell **)realloc(data, (nodes*nodes) * sizeof(struct cell*));
for(i=0;i<nodes*nodes;i++)
data[i] = (struct cell *)malloc(sizeof(struct cell));
for (i=0; i<nodes; i++)
{
for(j=0; j<nodes; j++)
{
| |
When I here try to add anything in any way to the two vectors vVectorFirstFs and vVectorLpId I get the error:
Access violation reading location
0xcdcdcdc1
Before I was getting an error like if i was trying to acces something beyond the boundaries of ther vector...
any hint on how can I manage this vector of vectors within a struct?
Thanks a lot
Francesco