Hi all,
I have a struct which contains not only basic data but other structs as well, some of which are large, I allocate my main struct the normal way and free it but I notice that it will crash on the free when I have too many larger structs within my main struct that I allocated mem for, it looks like this:
Code:
struct mainStruct {
int blah1;
int blah2;
bigStruct data1;
bigStruct data2;
bigStruct data3;
}
mainStruct myStruct = malloc(sizeof(mainStruct));
free(myStruct); // crash
is the correct practice to declare 'bigStruct' as a pointer and allocate mem for it, I've tried this and there is no problem but now i'm wondering about all the other places where I have structs within structs(most are pretty light) but what is the right thing to do here?
Thanks in advance...