If you call malloc like this:
myStruct *s = malloc(sizeof(myStruct ));
then you should call free on whatever pointer was returned from malloc (in this case called s
):
free(s);
The same thing goes if you call malloc like this:
myStruct *s = malloc(sizeof(myStruct) * NUM_IN_ARRAY);
//...
free(s);
Although, if you previously assigned a malloc'd pointer to a char* field in the structure, remember you need to free that as well.