Interview Questions and Answers :: Ericsson
Home > Experience Archives > Ericsson > Interview Question Set 2 > Discussion
9. When you do malloc() you need to pass the number of bytes that you require. But when you call free() you only pass the pointer. So, how the free() call detects how many bytes to free?
Answer:
When memory allocation is done, the actual heap space allocated is one word larger than the requested memory. The extra word is used to store the size of the allocation and is later used by free( )
Amit Singh
25 Aug, 2016 1:24 PM
When memory allocation is done, the actual heap space allocated is one word larger than the requested memory. The extra word is used to store the size of the allocation and is later used by free( )
Report Error
Report Error
Please Login First Click Here