Realloc problems with sturcture array inside structure
I have searched the forum and cant find the answer so i thought that i would ask.
I am using C and have the following two structures:
int origX, origY, origZ, maxLengthBool;
float dirX, dirY, dirZ;
You should be able to see that there is a pointer for branch in the tree sturucture.
I can assign memeory using calloc for the BRANCH pojnter/array
mainTree->branches = calloc(0,sizeof(BRANCH));
This works and creates an array of branches. But i jave a problem when i try and realloc the memory and increase the size of the array i use this code, which is part of a method/function:
tree->branches = realloc(tree->branches, brSize*sizeof(BRANCH));
Where brSize is the new size that i would like.
In windows using VC++ and openGL it causes a fatal error. I know it is this section, the realloc as the program doesnt get furthur than this point.
Can anyone suggest a solution as i am lost and dont understand the problem.