We have introduced some of the APIs dealing with memory allocation. As always, we have just covered the basics; more details are available elsewhere.
Read the C book“The C Programming Language” by Brian Kernighan, Dennis Ritchie. Prentice-Hall 1988. The C book, by the developers of C. Read it once, do some programming, then read it again, and then keep it near your desk or wherever you program. and Stevens (Chapter 7)“Advanced Programming in the UNIX Environment” by W. Richard Stevens, Stephen A. Rago. Addison-Wesley, 2005. We’ve said it before, we’ll say it again: read this book many times and use it as a reference whenever you are in doubt. The authors are always surprised at how each time they read something in this book, they learn something new, even after many years of C programming. for more information. For a cool modern paper on how to detect and correct many of these problems automatically, see Novark et al.“Exterminator: Automatically Correcting Memory Errors with High Probability” by G. Novark, E. D. Berger, B. G. Zorn. PLDI 2007, San Diego, California. A cool paper on finding and correcting memory errors automatically, and a great overview of many common errors in C and C++ programs. An extended version of this paper is available CACM (Volume 51, Issue 12, December 2008).; this paper also contains a nice summary of common problems and some neat ideas on how to find and fix them.