|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
A combination of realloc and calloc. Reallocates an array in memory and initializes its elements to 0.
Pointer to previously allocated memory block.
Number of elements.
Length in bytes of each element.
_recalloc returns a void pointer to the reallocated (and possibly moved) memory block.
If there is not enough available memory to expand the block to the given size, the original block is left unchanged, and NULL is returned.
If the requested size is zero, then the block pointed to by memblock is freed; the return value is NULL, and memblock is left pointing at a freed block.
The return value points to a storage space that is guaranteed to be suitably aligned for storage of any type of object. To get a pointer to a type other than void, use a type cast on the return value.
The _recalloc function changes the size of an allocated memory block. The memblock argument points to the beginning of the memory block. If memblock is NULL, _recalloc behaves the same way as and allocates a new block of num * size bytes. Each element is initialized to 0. If memblock is not NULL, it should be a pointer returned by a previous call to calloc, , or .
Because the new block can be in a new memory location, the pointer returned by _recalloc is not guaranteed to be the pointer passed through the memblock argument.
In Visual C++ 2005, _recalloc sets errno to ENOMEM if the memory allocation fails or if the amount of memory requested exceeds _HEAP_MAXREQ. For information on this and other error codes, see.
recalloc calls realloc in order to use the C++ _set_new_mode function to set the new handler mode. The new handler mode indicates whether, on failure, realloc is to call the new handler routine as set by _set_new_handler. By default, realloc does not call the new handler routine on failure to allocate memory. You can override this default behavior so that, when _recalloc fails to allocate memory, realloc calls the new handler routine in the same way that the new operator does when it fails for the same reason. To override the default, call
early in the program, or link with NEWMODE.OBJ.
When the application is linked with a debug version of the C run-time libraries, _recalloc resolves to The CRT Debug Heap.. For more information about how the heap is managed during the debugging process, see
_recalloc is marked __declspec(noalias) and __declspec(restrict), meaning that the function is guaranteed not to modify global variables, and that the pointer returned is not aliased. For more information, see noalias and restrict.
<stdlib.h> and <malloc.h>
ANSI, Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003
For additional compatibility information, see Compatibility in the Introduction.
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.