I have the following code:
#define MAX_NUMBER_OF_FRAMES 10
typedef struct my_frame_header {
unsigned int ul_Src;
unsigned int ul_Dest;
} MY_FRAME_HEADER;
typedef struct my_frame {
MY_FRAME_HEADER x_FrameHeader;
unsigned char uc_Frame[3000];
} MY_FRAME;
int main(int argc, char *argv[])
{
MY_FRAME *px_MyFrames;
px_MyFrames = (MY_FRAME *)malloc(sizeof(MY_FRAME) * MAX_NUMBER_OF_FRAMES);
// Use the x_MyFrames variable like an array
px_MyFrames[0].uc_Frame[0] = 10;
//free px_MyFrames
free(px_MyFrames);
return 1;
}
Will all the memory be succesfully freed? or do I need to make uc_Frame a pointer and malloc memory in an Init function of MY_FRAME? And then in the destructor free the memory for each uc_Frame of px_MyFrames and then free px_MyFrames? (Sorry if there are any compiler errors, I just wrote on the fly to give you the basic idea). If the way I put it here is not the right one and there are memory problems could you explain what those problems might be?.