Mono Class Library: Mono.Unix.Native.Stdlib Overview | MembersMono.Unix.Native.Stdlib.malloc Method |
Allocate memory. [Edit]
|
- size
- Amount of memory to allocate. [Edit]
The malloc() function returns a pointer to the allocated memory if successful; otherwise a IntPtr.Zero pointer is returned and Stdlib.GetLastError returns Errno.ENOMEM. [Edit]
The malloc() function allocates size bytes of memory. The allocated space is suitably aligned (after possible pointer coercion) for storage of any type of object. If the space is at least pagesize bytes in length (see Syscall.getpagesize(3)), the returned memory will be page boundary aligned as well. If malloc() fails, IntPtr.Zero is returned.
You should Stdlib.free the return value to avoid a memory leak.
Note that malloc() does NOT normally initialize the returned memory to zero bytes.
[Edit]
Namespace: Mono.Unix.Native
Assembly: Mono.Posix (in Mono.Posix.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0