C Memory Functions

malloc (long size): void*

Allocates a contiguous memory area with the given size in bytes. This can be used to create arrays of dynamic size.

Parameters:

size - Size of the allocated memory area, in bytes.

Returns:

void* pointer to the allocated memory area, or NULL when the allocation failed.
 

free (void* ptr)

Releases a contiguous memory area that was allocated with malloc.

Parameter:

ptr - void* pointer to the allocated memory area.
 

memcpy (void* dest, void* src, long size)

Copies size bytes from src to dest. Can be used to copy a whole struct or array with a single function.

Parameters:

dest - Target address.
src - Source address.
size - Number of bytes to copy.
 

memset (void* dest, int c, long size)

Sets the first size characters of dest to the character c. Can be used to initialize a whole struct or array to zero.

Parameters:

dest - Target address.
c - value to copy, 0..255.
size - Number of bytes to copy.
 

Remarks:

Example:

See http

See also:

sizeof, memory

► latest version online