ok, here goes...
If I have fp = malloc(3*sizeof(int)); fp now points to the memory address of the first int of 3 that have been allocated for my use. When I use free(fp); it frees those 3 ints.
How does it know that 3 ints worth of space need to be freed? All I passed in was a pointer to the first one. Is there some sort of marker in memory that says this is where a set of allocated memory ends? Or is this kept track of somewhere else?
i.e. if I were to advance the pointer by one int fp = fp+sizeof(int); and then free(fp); would the 2 remaining ints be freed? or would 3 ints be freed? or would I get some sort of error?
sorry I don't understand malloc yet, thanks for any help,