内存分配Memory Allocation

使用这些例程分配、释放和重新分配内存。Use these routines to allocate, free, and reallocate memory.

内存分配例程Memory-Allocation Routines

例程Routine 使用Use
_alloca_malloca_alloca, _malloca 从堆栈中分配内存Allocate memory from stack
calloccalloc 为数组分配内存,从而将分配的块中的每个字节初始化为 0Allocate storage for array, initializing every byte in allocated block to 0
_calloc_dbg_calloc_dbg calloc 的调试版本;仅在运行时库的调试版本中可用Debug version of calloc; only available in the debug versions of the run-time libraries
运算符 deleteoperator delete 释放分配的块Free allocated block
运算符 []operator delete[] 释放分配的块Free allocated block
_expand_expand 展开或收缩内存块,而无需移动它Expand or shrink block of memory without moving it
_expand_dbg_expand_dbg _expand 的调试版本;仅在运行时库的调试版本中可用Debug version of _expand; only available in the debug versions of the run-time libraries
freefree 释放分配的块Free allocated block
_free_dbg_free_dbg free 的调试版本;仅在运行时库的调试版本中可用Debug version of free; only available in the debug versions of the run-time libraries
_freea_freea 从堆栈中释放分配的块Free allocated block from stack
_get_heap_handle_get_heap_handle 获取 CRT 堆的 Win32 HANDLE。Get Win32 HANDLE of the CRT heap.
_heapadd_heapadd 将内存添加到堆Add memory to heap
_heapchk_heapchk 检查堆的一致性Check heap for consistency
_heapmin_heapmin 释放堆中未使用的内存Release unused memory in heap
_heapset_heapset 使用指定值填充可用的堆条目Fill free heap entries with specified value
_heapwalk_heapwalk 返回有关堆中每个条目的信息Return information about each entry in heap
mallocmalloc 从堆中分配内存块Allocate block of memory from heap
_malloc_dbg_malloc_dbg malloc 的调试版本;仅在运行时库的调试版本中可用Debug version of malloc; only available in the debug versions of the run-time libraries
_msize_msize 返回分配的块的大小Return size of allocated block
_msize_dbg_msize_dbg _msize 的调试版本;仅在运行时库的调试版本中可用Debug version of _msize; only available in the debug versions of the run-time libraries
newnew 从堆中分配内存块Allocate block of memory from heap
new[]new[] 从堆中分配内存块Allocate block of memory from heap
_query_new_handler_query_new_handler 返回由 _set_new_handler 设置的当前新处理程序例程的地址Return address of current new handler routine as set by _set_new_handler
_query_new_mode_query_new_mode 返回指示由 _set_new_modemalloc 设置的新处理程序模式的整数Return integer indicating new handler mode set by _set_new_mode for malloc
reallocrealloc 将块重新分配到新大小Reallocate block to new size
_realloc_dbg_realloc_dbg realloc 的调试版本;仅在运行时库的调试版本中可用Debug version of realloc; only available in the debug versions of the run-time libraries
_set_new_handler_set_new_handler new 运算符失败(无法分配内存)时启用错误处理机制,然后启用 C++ 标准库的编译Enable error-handling mechanism when new operator fails (to allocate memory) and enable compilation of C++ Standard Libraries
_set_new_mode_set_new_mode 设置 malloc 的新处理程序模式Set new handler mode for malloc

另请参阅See Also

按类别分的运行时例程Run-Time Routines by Category