The Linux Programming Interface

(nextflipdebug5) #1

152 Chapter 7


7.4 Exercises


7-1. Modify the program in Listing 7-1 (free_and_sbrk.c) to print out the current value of
the program break after each execution of malloc(). Run the program specifying a
small allocation block size. This will demonstrate that malloc() doesn’t employ sbrk()
to adjust the program break on each call, but instead periodically allocates larger
chunks of memory from which it passes back small pieces to the caller.
7-2. (Advanced) Implement malloc() and free().
Free download pdf