Original Post
I''m using the following dtructure:
struct s_bone
{
s_key *Key;
inr KeyNum;
};
struct s_sam
{
int NumBones;
s_bone *bone;
};
of course there are other elements in the structs, removed to save space. I then allocate some memory like this:
Sam.bone=(s_bone*)malloc(sizeof(s_bone) * Sam.NumBones);
after that I allocate memory for the keys in every single bone:
for(i=0; i.Key = (s_key*)malloc(sizeof(s_key) * Sam.bone[i].KeyNum);
everything OK so far, works great (I hope there are no errors so far). But now, at the end of the program I want to free the memory. Now the question: is it sufficient to free the Sam.bone, or will I have to free every key first, and then, afterwards the bone? I tried the latter, first freeing the keys, and the bones afterwards, but I get an Runtime Error here. No error if I just free the Sam.bone. But If I just free them, is there a memory leak? THX,,
NoNseNse