Resizes a block of memory previously allocated with Marshal.AllocHGlobal(IntPtr).
- pv
- A pointer to memory allocated with Marshal.AllocHGlobal(IntPtr).
- cb
- The new size of the allocated block. This is not a pointer; it is the byte count you are requesting, cast to type IntPtr. If you pass a pointer, it is treated as a size.
A pointer to the reallocated memory. This memory must be released using Marshal.FreeHGlobal(IntPtr).
Marshal.ReAllocHGlobal(IntPtr, IntPtr) is one of two memory reallocation API methods in the System.Runtime.InteropServices.Marshal class. (Marshal.ReAllocCoTaskMem(IntPtr, int) is the other.)
This method exposes the Win32 tp://go.microsoft.com/fwlink/?LinkId=148780 function from Kernel32.dll. The returned pointer can differ from the original. If it is different, the contents of the original memory block have been copied to the new block, and the original memory block has been freed.