malloc

Syntax

void* malloc(int size)

Arguments

size
The size of the memory to be reserved, measured in bytes.

Return

A pointer to the allocated memory.

Description

Reserves size bytes memory.

If the memory could be allocated, a pointer to the first element in the reserved memory block is returned.

If the memory could not be allocated (e.g. due to memory shortage or a high degree of memory fragmentation), a NULL value is returned instead.

Any memory reserved by use of this function must be manually deallocated by means of the free function, failure to do so will result in memory leakage and will ultimately crash the system.

Example

%ffp

OnFilterStart:
{
    // Allocate a string for
    // 255 characters
    char* buffer_1 = malloc(255);

    free(buffer_1);
}

See Also

calloc, free, realloc