This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ementation of explicit allocators. We will discuss implicit allocators in Section 10.10. For concreteness, our discussion focuses on allocators that manage heap memory. However, students should be aware that memory allocation is a general idea that arises in a variety of contexts. For example, applications that do intensive manipulation of graphs will often use the standard allocator to acquire a large block of virtual memory, and then use an application-speciﬁc allocator to manage the memory within that block as the nodes of the graph are created and destroyed. 10.9.1 The malloc and free Functions
The C standard library provides an explicit allocator known as the malloc package. Programs allocate blocks from the heap by calling the malloc function.
#include <stdlib.h> void *malloc(size t size);
returns: ptr if OK, NULL on error The malloc function returns a pointer to a block of memory of at least size bytes that is suitably aligned for any kind of data object that might be contained in the block. On the Unix systems t...
View Full Document