4 bytes because even if you call malloc and free a little more frequently, that might still occur. malloc frequently uses the extra space for managing (a linked list of all memory blocks and their sizes) when it takes a few bytes more than what is requested.
There is a good chance that you will tamper with the internal management structures and cause the subsequent malloc of free will to crash if you write some bytes either before or after your allocated block.
4004 because malloc internally always allocates at least four bytes. Your program would be 4000 if you added four bytes, making it 4004. may crash only when you access byte n+1. Additionally, the operating system typically only protects pages of memory.
Your process may be able to read-write the remainder of the page and will only crash when accessing the next memory page if your malloc-ed byte is in the middle of a page with a size of 512 bytes. But keep in mind: Even if this works, the behavior is not clear.
To learn more about internal management here
brainly.com/question/13398903
#SPJ1
Full Question = Suppose a malloc implementation returns 8-byte aligned addresses and uses an explicit free list where the next and previous pointers are each 32-bits. Blocks have a 32-bit header and 32-bit footer, where the low-order bit of the header and footer are used to indicate whether the block is allocated (1) or free (0). Furthermore, the block size (which includes the header, payload, footer, and any necessary padding) is rounded up to the nearest multiple of 8, and this size (in bytes) is stored in the header and footer. Assume any padding must be between the payload and the footer.
a) If we call malloc(1), what block size will be allocated, in bytes?
b) With the same conditions, and assuming we've already called malloc(1), if the heap used by malloc starts at address 0x4000 (16384 in decimal), what address would be returned if we then called malloc(32)?