912 putting it together implementing a simple

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: p consists of a single 16-word double-word aligned free block. ¯ ¯ ¯ ¯ ¯ Figure 10.36(a): The program asks for a 4-word block. Malloc responds by carving out a 4-word block from the front of the free block and returning a pointer to the first word of the block. Figure 10.36(b): The program requests a 5-word block. Malloc responds by allocating a 6-word block from the front of the free block. In this example, malloc pads the block with an extra word in order to keep the free block aligned on a double-word boundary. Figure 10.36(c): The program requests a 6-word block and malloc responds by carving out a 6-word block from the free block. Figure 10.36(d) The program frees the 6-word block that was allocated in Figure 10.36(b). Notice that after the call to free returns, the pointer p2 still points to the freed block. It is the responsibility of the application not to use p2 again until it is reinitialized by a new call to malloc. Figure 10.36(e): The program requests a 2-word block....
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online