I am trying to change the size of a matrix for a graph dynamically.
Code :
void addNumToGraph(vertex** tracker, int inNum, int i, int** graphMatrix)
{
    tracker = (vertex**)realloc(tracker, i*sizeof(vertex*));
    if (sizeof(tracker)/sizeof(vertex*) < inNum)
    {
        graphMatrix = (int**)realloc(graphMatrix, sizeof(int*)*inNum);
        for (i = 0; i < sizeof(graphMatrix)/sizeof(int*); i++)
        {
            //I am getting the error on the line below
            graphMatrix[i] = (int*)realloc(graphMatrix[i], sizeof(int)*inNum);
        }
    }
    tracker[i]->color = 0;
    tracker[i]->distance = -1;
    tracker[i]->father = NULL;
    tracker[i]->value = inNum;
    tracker[i]->index = i;
    }
The function above is being called from a while loop:
while (inChar != '|')
{
    //will scan the vertex number
    scanf("%d", &inNum);
    addNumToGraph(tracker, inNum, i, graph);
    i++;
    //will scan the ','
    scanf("%c", &inChar);
}
which is located in another function.
graph is a local double pointer in the function
- I tried two methods: initializing the graph to NULL and initializing it with a malloc so it will not be empty
Both evaluated in the same result:
the error -
"getting error Unhanded exception at (msvcr120d.dll) in Access violation reading location......"
The error appears on the same line of code each time:
graphMatrix[i] = (int*)realloc(graphMatrix[i], sizeof(int)*inNum);
Dos anyone know what I am doing wrong?
 
     
     
    