Answers/Solutions to Exercises in Chapter 4, Exercise 9

E9: The allocators malloc(), calloc(), and realloc(), and the deallocator free() work in a close relationship with the operating system. So how come a program using them can be compiled by various compilers and executed on various machines?

A9: This is true for any standard function. Their implementation is not "prescribed", but their behaviour is well-defined and it is the responsibility of the compiler producer to create the functions that behave according to the standard specification. So no matter at what machine, what platform, and what compiler, malloc() is guaranteed to behave as expected (in theory, anyway).

Back to Answers/Solutions Index                          Back to Answers/Solutions for Chapter 4 Index