Memory Management: Resizable Memory Blocks

The new and delete operators, described in the article Memory Management: Examples, 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 with the resizable memory-allocation functions on the same memory block will result in corrupted memory in the Debug version of MFC. You should not use realloc on a memory block allocated with new. Likewise, you should not allocate a memory block with the new operator and delete it with free, or use the delete operator on a block of memory allocated with malloc.

See Also

Concepts

Memory Management: Heap Allocation