Everything

malloc


Memory allocation(not initialized to zero)

[Classification]

Standard library

[Syntax]

#include <stdlib.h>

void *malloc(size_t size);

[Return value]

When area allocation succeeds, a pointer to that area is returned. When the area could not be allocated, a null pointer is returned.

[Description]

This function allocates an area having a size indicated by size. The area is not initialized.

[Caution]

The memory area management functions automatically allocate memory area as necessary from the heap memory area.

Also, the size of the default is 0x1000 bytes, so when it's changed, the heap memory area must be allocated. The area allocation should be performed first by an application.

 

[Heap memory setup example]

#include    <stddef.h>
#define     SIZEOF_HEAP 0x1000
int     _REL_sysheap[SIZEOF_HEAP >> 2];
size_t  _REL_sizeof_sysheap = SIZEOF_HEAP;

Remark 1.

The variable "_REL_sysheap" points to the starting address of heap memory. This value must be a multiple of 4.

Remark 2.

The required heap memory size (bytes) should be set for the variable "_REL_sizeof_sysheap".