Hi Guys, got a question here about malloc and free calls...

Say I want to allocate a dynamic array of struct, I go something like

tydef struct somestruct mystruct;
mystruct *pt = (mystruct*)malloc(num*sizeof(mystruct));


So I can do pointer arthmetic right? For example:

mystruct *temp_pt = pt;
for(i = 0; i < num; i++)
// do some work with temp_pt

Now, my question is....if I want to free up the allocated memory, do I have to do it individually:

mystruct *temp_pt = pt;
for(i = 0; i < num; i++)
{
free(temp_pt);
temp_pt++;
}

or: I only have to free from the base of the allocated memory:

free(pt);



Thanks in advance!