Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Marshal.ReAllocCoTaskMem Method

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;

Parameters

pv
A pointer to memory allocated with AllocCoTaskMem.
cb
The new size of the allocated block.

Return Value

An integer representing the address of the block of memory reallocated. This memory must be released with FreeCoTaskMem.

Exceptions

Exception Type Condition
OutOfMemoryException There is insufficient memory to satisfy the request.

Remarks

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.

Requirements

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: 

See Also

Marshal Class | Marshal Members | System.Runtime.InteropServices Namespace | ReAllocHGlobal | FreeCoTaskMem

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.