Mono Class Library: Mono.Unix.Native.Stdlib Overview | Members

Mono.Unix.Native.Stdlib.realloc Method

Reallocate a memory block. [Edit]

[System.CLSCompliant(false)]
public static IntPtr realloc (IntPtr ptr, ulong size)

Parameters

ptr
Pointer to the start of a memory area to reallocate. [Edit]
size
The new size for the allocated memory. [Edit]

Returns

The realloc() function returns a pointer, possibly identical to ptr, to the allocated memory if successful; otherwise a IntPtr.Zero pointer is returned and Stdlib.GetLastError returns Errno.ENOMEM. The realloc() function always leaves the original buffer intact when an error occurs. [Edit]

Remarks

The realloc() function changes the size of the previously allocated memory referenced by ptr to size bytes. 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. 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. If ptr is IntPtr.Zero, the realloc() function behaves identically to Stdlib.malloc() for the specified size. [Edit]

Requirements

Namespace: Mono.Unix.Native
Assembly: Mono.Posix (in Mono.Posix.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0