Export (0) Print
Expand All
Expand Minimize

_realloc_dbg

Reallocates a specified block of memory in the heap by moving and/or resizing the block (debug version only).

void *_realloc_dbg(
   void *userData,
   size_t newSize,
   int blockType,
   const char *filename,
   int linenumber 
);

Parameters

userData
Pointer to the previously allocated memory block.
newSize
Requested size for reallocated block (bytes).
blockType
Requested type for reallocated block: _CLIENT_BLOCK or _NORMAL_BLOCK.
filename
Pointer to name of source file that requested realloc operation or NULL.
linenumber
Line number in source file where realloc operation was requested or NULL.

The filename and linenumber parameters are only available when _realloc_dbg has been called explicitly or the _CRTDBG_MAP_ALLOC preprocessor constant has been defined.

Return Value

Upon successful completion, this function either returns a pointer to the user portion of the reallocated memory block, calls the new handler function, or returns NULL. See the following Remarks section for a complete description of the return behavior. See the realloc function for more information on how the new handler function is used.

Remarks

_realloc_dbg is a debug version of the realloc function. When _DEBUG is not defined, each call to _realloc_dbg is reduced to a call to realloc. Both realloc and _realloc_dbg reallocate a memory block in the base heap, but _realloc_dbg accommodates several debugging features: buffers on either side of the user portion of the block to test for leaks, a block type parameter to track specific allocation types, and filename/linenumber information to determine the origin of allocation requests.

_realloc_dbg reallocates the specified memory block with slightly more space than the requested newSize. newSize may be greater or less than the size of the originally allocated memory block. The additional space is used by the debug heap manager to link the debug memory blocks together and to provide the application with debug header information and overwrite buffers. The reallocation may result in moving the original memory block to a different location in the heap, as well as changing the size of the memory block. If the memory block is moved, the contents of the original block are copied over.

For information about how memory blocks are allocated, initialized, and managed in the debug version of the base heap, see Memory Management and the Debug Heap. For information about the allocation block types and how they are used, see Types of Blocks on the Debug Heap. For information on the differences between calling a standard heap function versus its debug version in a debug build of an application, see Using the Debug Version Versus the Base Version.

Requirements

Routine Required header Compatibility
_realloc_dbg <crtdbg.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.

Libraries

Debug versions of C run-time libraries only.

Example

See the example in the _msize_dbg topic.

See Also

Debug Functions | _malloc_dbg | Run-Time Routines and .NET Framework Equivalents

Show:
© 2014 Microsoft