In case 2 the current block is merged with the next

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: hat we are familiar with, malloc returns a block that is aligned to an 8-byte (double-word) boundary. The size t type is defined as an unsigned int. Aside: How big is a word? Recall from our discussion of IA32 machine code in Chapter 3 that Intel refers to 4-byte objects as double-words. However, throughout this section we will assume that words are 4-byte objects and that double-words are 8-byte objects, which is consistent with conventional terminology. End Aside. If malloc encounters a problem (e.g., the program requests a block of memory that is larger than the available virtual memory), then it returns NULL and sets errno. Malloc does not initialize the memory it returns. Applications that want initialized dynamic memory can use calloc, a thin wrapper around the malloc function that initializes the allocated memory to zero. Applications that want to change the size of a previously allocated block can use the realloc function. Dynamic memory allocators such as malloc can allocate or deallocate heap memory explicitly by using the mmap and munmap functions, or they can use the sbrk function: #include <unistd.h> void *sbrk(int incr); returns: old brk pointer on success, -1 on error 524 CHAPTER 10. V...
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