C coding tip: Self-manage data buffer memory
Posted on: 01/07/2004 03:07 PM
The C programming language defines two standard memory management functions: malloc() and free(). C programmers frequently use those functions to allocate buffers at run time to pass data between functions. In many situations, however, you cannot predetermine the actual sizes required for the buffers, which may cause several fundamental problems for constructing complex C programs. This article advocates a self-managing, abstract data buffer
. It outlines a pseudo-C implementation of the abstract buffer and details the advantages of adopting this mechanism.