Mono Class Library: Mono.Unix.UnixMarshal Overview | MembersMono.Unix.UnixMarshal.ReAllocHeap Method |
Changes the size of the memory block ptr to refer to size bytes of memory on the system heap. [Edit]
|
- ptr
- A IntPtr containing the address of the memory block to resize. This value must either be IntPtr.Zero or a value previously returned by UnixMarshal.AllocHeap or UnixMarshal.ReAllocHeap. [Edit]
- size
- A long containing the number of bytes to allocate on the system heap. [Edit]
A IntPtr containing the address of size bytes on the system heap, or IntPtr.Zero if the memory could not be allocated.
Note: If IntPtr.Zero is returned, ptr is still a valid memory address, and must still be freed.[Edit]
Type Reason ArgumentOutOfRangeException size is a negative value. [Edit]
This function changes the size of the previously allocated memory referenced by ptr to size bytes. ptr must have been previously allocated via UnixMarshal.AllocHeap or UnixMarshal.ReAllocHeap, or ptr must be the value IntPtr.Zero (in which case this method is identical to UnixMarshal.AllocHeap). The contents of the memory are unchanged up to the lesser of the new and old sizes. If the new size is larger, the value of the newly allocated portion of the memory is undefined.
The memory allocated by this function must be freed via UnixMarshal.FreeHeap to avoid a memory leak.
Note:If the requested memory cannot be allocated, IntPtr.Zero is returned and the memory referenced by ptr is valid and unchanged.
If memory can be allocated, the memory referenced by ptr is freed and a pointer to the newly allocated memory is returned. Note that this may be different from the value passed as ptr.
The "system heap" is where dynamic memory is allocated by the runtime C library, MSVCRT.DLL on Win32 and libc on Unix platforms.
[Edit]
Namespace: Mono.Unix
Assembly: Mono.Posix (in Mono.Posix.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0