I have following code snippet -
int *createIncidenc eMatrix(int numEdges, int numVertices) {
int *p = (int *) calloc((numEdge s*numVertices), sizeof(int));
if(p == NULL) {
printf("Could not allocate memory");
exit(0);
}
return p;
}
void createIncidence PerView(int numEdges, int numVertices, int viewId) {
int *pnew = createIncidence Matrix(numEdges , numVertices);
}
This code compiles fine. I am trying to understand if this will run as
intended. Obviously, I tried running the code also. My question is -
When createIncidence Matrix() return p which is local variable, will p
get deallocated at return call ?
So when i make createIncidence Matrix() call inside
createIncidence PerView(), will the call createIncidence Matrix() tries to
assign deallocated local pointer to the pnew pointer ?
Thanks
Mahendra
int *createIncidenc eMatrix(int numEdges, int numVertices) {
int *p = (int *) calloc((numEdge s*numVertices), sizeof(int));
if(p == NULL) {
printf("Could not allocate memory");
exit(0);
}
return p;
}
void createIncidence PerView(int numEdges, int numVertices, int viewId) {
int *pnew = createIncidence Matrix(numEdges , numVertices);
}
This code compiles fine. I am trying to understand if this will run as
intended. Obviously, I tried running the code also. My question is -
When createIncidence Matrix() return p which is local variable, will p
get deallocated at return call ?
So when i make createIncidence Matrix() call inside
createIncidence PerView(), will the call createIncidence Matrix() tries to
assign deallocated local pointer to the pnew pointer ?
Thanks
Mahendra
Comment