Shailendra B. answered 03/29/19
Software technical lead with 28 years experience in Embedded/Linux/C
You cannot pass any kind of pointer to free(). You can only pass the pointer that was earlier allocated via
malloc/calloc/strdup
Besides, you can also do free(NULL) and it would be ignored.
The memory block that is returned by malloc/calloc/strdup is of slightly more size than requested by the user. There is a small control header preceding the user pointer and that contains control information about the block and possibly other elements in the heap.