Resizes a block of memory previously allocated with AllocCoTaskMem.
[Visual Basic] Public Shared Function ReAllocCoTaskMem( _ ByVal pv As IntPtr, _ ByVal cb As Integer _ ) As IntPtr [C#] public static IntPtr ReAllocCoTaskMem( IntPtr pv, int cb ); [C++] public: static IntPtr ReAllocCoTaskMem( IntPtr pv, int cb ); [JScript] public static function ReAllocCoTaskMem( pv : IntPtr, cb : int ) : IntPtr;
- A pointer to memory allocated with AllocCoTaskMem.
- The new size of the allocated block.
An integer representing the address of the block of memory reallocated. This memory must be released with FreeCoTaskMem.
|OutOfMemoryException||There is insufficient memory to satisfy the request.|
ReAllocCoTaskMem is one of two memory reallocation API methods in the Marshal class. (ReAllocHGlobal is the other.) The beginning of the reallocated memory content is the same as the original content; however, the entire memory block can be in a different location. This method exposes the CoTaskMemRealloc COM API method, which is referred to as the COM task memory allocator. For additional information about CoTaskMemRealloc, see the MSDN Library.
Note This method uses SecurityAction.LinkDemand to prevent it from being called from untrusted code; only the immediate caller is required to have SecurityPermissionAttribute.UnmanagedCode permission. If your code can be called from partially trusted code, do not pass user input to Marshal class methods without validation. For important limitations on using the LinkDemand member, see Demand vs. LinkDemand.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
- SecurityPermission for operating with unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode.