Resizable Memory Blocks

The new and delete operators described above are good for allocating and deallocating fixed-size memory blocks and objects. Occasionally, your application may need resizable memory blocks. You must use the standard C run-time library functions malloc, realloc, and free to manage resizable memory blocks on the heap.

Mixing the new and delete operators and the resizable memory-allocation functions on the same memory block will result in corrupted memory in the Debug version of the Foundation Class Library. That is, you should not allocate a memory block with new and deallocate it with free. Likewise, you should not use the C++ delete operator on a memory block allocated with malloc and you should not use realloc on a memory block allocated with new.