网站首页  词典首页

请输入您要查询的函数:

 

术语 heaprealloc
释义 HeapReAlloc
语法:
C++
LPVOID WINAPI HeapReAlloc(
__in HANDLE hHeap,
__in DWORD dwFlags,
__in LPVOID lpMem,
__in SIZE_T dwBytes
);
HeapReAlloc功能
重新分配块从堆中的内存。此功能使您能够调整内存块和变化的其他内存块的属性。分配的内存不是移动。
参数
hHeap [in]
阿堆句柄从该内存被重新分配。这是一个返回的句柄不论是由HeapCreate或GetProcessHeap功能。
dwFlags [in]
堆分配方案。指定的值将覆盖相应的价值时,堆使用HeapCreate函数创建flOptions参数指定。此参数可以是一个或多个下列值。
ValueMeaning
HEAP_GENERATE_EXCEPTIONS
0x00000004The操作系统引发一个异常,以指示如外的内存不足的情况,而不是返回NULL,功能衰竭。
为确保例外生成所有这函数调用,指定在调用HEAP_GENERATE_EXCEPTIONS的HeapCreate。在这种情况下,没有必要的补充规定,在此函数调用HEAP_GENERATE_EXCEPTIONS。
HEAP_NO_SERIALIZE
0x00000001Serialized访问将不会被使用。有关更多信息,请参见备注。
为了确保序列化的访问被禁用所有这个函数调用,指定在调用HEAP_NO_SERIALIZE的HeapCreate。在这种情况下,没有必要的补充规定,在此函数调用HEAP_NO_SERIALIZE。
此值不应访问时指定进程堆。该系统可在应用中创建的过程中,如按Ctrl + C处理,即同时访问进程堆额外的线程。
HEAP_REALLOC_IN_PLACE_ONLY
0x00000010There不能移动时,重新分配一个内存块。如果该值未指定,该函数可能会阻止移动到新位置。如果此值被指定,块不能没有移动大小,功能失败,使原来的内存块不变。
HEAP_ZERO_MEMORY
0x00000008If要求重新分配较大的大小,内存超越了原来的大小的其他地区被初始化为零。该内存块至其原始大小的内容不会受到影响。
lpMem [in]
一个内存块指针,重新分配的功能。该指针是由一个先前调用HeapAlloc或HeapReAlloc功能。
dwBytes [in]
该内存块的新的大小,以字节为单位。内存块的大小,可以增加或减少使用此功能。
如果堆的hHeap参数指定为“非可增长的”堆,dwBytes必须小于0x7FFF8。您通过电话与一个非零值HeapCreate函数非可增长堆。
返回值
如果函数成功,返回值是一个重新分配的内存块的指针。
如果函数失败,并且没有指定HEAP_GENERATE_EXCEPTIONS,返回值为NULL。
如果函数失败,并且您已指定HEAP_GENERATE_EXCEPTIONS,功能可能会生成以下例外。
返回codeDescription
STATUS_NO_MEMORYThe分配尝试失败的可用内存不足。
STATUS_ACCESS_VIOLATIONThe分配尝试失败,因为堆损坏或不当函数参数。
如果函数失败,它不会调用SetLastError。应用程序不能要求扩展的错误信息GetLastError函数。
备注
最少的内存量,如果HeapReAlloc成功,它分配的要求。
如果HeapReAlloc失败,原来的内存不释放,和原处理和指针仍然有效。
HeapReAlloc是保证维护存储器中的内容被重新分配,即使在新的内存分配一个不同的位置。在保留内存内容的过程涉及到内存复制操作可能非常耗时。
释放一个由HeapReAlloc分配的内存块,使用HeapFree功能。
序列化,确保相互排斥的两个或多个线程试图同时分配或来自同一堆空闲块。有一个小的性能成本的序列化,但必须使用多线程分配时,从同一个堆的可用内存。设置HEAP_NO_SERIALIZE价值消除了堆相互排斥。没有系列化,两个或多个线程使用同一个堆句柄可能试图分配或释放内存同时,在堆可能滋生腐败。该HEAP_NO_SERIALIZE值,因此,可以放心使用只有在下列情况下:
这个过程只有一个线程。
这一进程的多个线程,但只有一个线程调用特定堆的堆函数。
这一进程的多个线程,并且应用程序提供了相互排斥的机制,以一个特定的堆。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
堆函数
HeapAlloc
HeapFree
内存管理功能
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==HeapReAlloc Function
Reallocates a block of memory from a heap. This function enables you to resize a memory block and change other memory block properties. The allocated memory is not movable.
Syntax
C++
LPVOID WINAPI HeapReAlloc(
__in HANDLE hHeap,
__in DWORD dwFlags,
__in LPVOID lpMem,
__in SIZE_T dwBytes
);
Parameters
hHeap [in]
A handle to the heap from which the memory is to be reallocated. This handle is a returned by either the HeapCreate or GetProcessHeap function.
dwFlags [in]
The heap reallocation options. Specifying a value overrides the corresponding value specified in the flOptions parameter when the heap was created by using the HeapCreate function. This parameter can be one or more of the following values.
ValueMeaning
HEAP_GENERATE_EXCEPTIONS
0x00000004The operating-system raises an exception to indicate a function failure, such as an out-of-memory condition, instead of returning NULL.
To ensure that exceptions are generated for all calls to this function, specify HEAP_GENERATE_EXCEPTIONS in the call to HeapCreate. In this case, it is not necessary to additionally specify HEAP_GENERATE_EXCEPTIONS in this function call.
HEAP_NO_SERIALIZE
0x00000001Serialized access will not be used. For more information, see Remarks.
To ensure that serialized access is disabled for all calls to this function, specify HEAP_NO_SERIALIZE in the call to HeapCreate. In this case, it is not necessary to additionally specify HEAP_NO_SERIALIZE in this function call.
This value should not be specified when accessing the process heap. The system may create additional threads within the application's process, such as a CTRL+C handler, that simultaneously access the process heap.
HEAP_REALLOC_IN_PLACE_ONLY
0x00000010There can be no movement when reallocating a memory block. If this value is not specified, the function may move the block to a new location. If this value is specified and the block cannot be resized without moving, the function fails, leaving the original memory block unchanged.
HEAP_ZERO_MEMORY
0x00000008If the reallocation request is for a larger size, the additional region of memory beyond the original size be initialized to zero. The contents of the memory block up to its original size are unaffected.

lpMem [in]
A pointer to the block of memory that the function reallocates. This pointer is returned by an earlier call to the HeapAlloc or HeapReAlloc function.
dwBytes [in]
The new size of the memory block, in bytes. A memory block's size can be increased or decreased by using this function.
If the heap specified by the hHeap parameter is a "non-growable" heap, dwBytes must be less than 0x7FFF8. You create a non-growable heap by calling the HeapCreate function with a nonzero value.
Return Value
If the function succeeds, the return value is a pointer to the reallocated memory block.
If the function fails and you have not specified HEAP_GENERATE_EXCEPTIONS, the return value is NULL.
If the function fails and you have specified HEAP_GENERATE_EXCEPTIONS, the function may generate the following exceptions.
Return codeDescription
STATUS_NO_MEMORYThe reallocation attempt failed for lack of available memory.
STATUS_ACCESS_VIOLATIONThe reallocation attempt failed because of heap corruption or improper function parameters.

If the function fails, it does not call SetLastError . An application cannot call GetLastError for extended error information.
Remarks
If HeapReAlloc succeeds, it allocates at least the amount of memory requested.
If HeapReAlloc fails, the original memory is not freed, and the original handle and pointer are still valid.
HeapReAlloc is guaranteed to preserve the content of the memory being reallocated, even if the new memory is allocated at a different location. The process of preserving the memory content involves a memory copy operation that is potentially very time-consuming.
To free a block of memory allocated by HeapReAlloc, use the HeapFree function.
Serialization ensures mutual exclusion when two or more threads attempt to simultaneously allocate or free blocks from the same heap. There is a small performance cost to serialization, but it must be used whenever multiple threads allocate and free memory from the same heap. Setting the HEAP_NO_SERIALIZE value eliminates mutual exclusion on the heap. Without serialization, two or more threads that use the same heap handle might attempt to allocate or free memory simultaneously, likely causing corruption in the heap. The HEAP_NO_SERIALIZE value can, therefore, be safely used only in the following situations:
The process has only one thread.
The process has multiple threads, but only one thread calls the heap functions for a specific heap.
The process has multiple threads, and the application provides its own mechanism for mutual exclusion to a specific heap.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
Heap Functions
HeapAlloc
HeapFree
Memory Management Functions
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa366704(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:21:55