INtime SDK Help

Allocates a memory block of the specified size.

Note:   malloc allocates physical memory to the current process's Vseg as required. free() never physically releases memory allocated by malloc.
#include <stdlib.h>
void *malloc (size_t size);

void *_malloc_internal (size_t size);


Bytes to allocate.


The allocated block may be larger than the specified size, including space required for alignment and maintenance information. The memory is suitably aligned for storage of any type of object.

Always examine the return from malloc, even if the amount of memory requested is small.

_malloc_internal behaves identically to malloc, use it to implement your own debug version of malloc.

Return Values

A pointer to the allocated space. To get a pointer to a type other than void, use a type cast on the return value. For a size of 0 bytes, malloc returns a NULL.
Returns a NULL pointer.
Note: For a size of 0 bytes, the NULL returned by malloc is a non-standard implementation. A call to malloc may fail due to physical memory exhaustion (ENOMEM) or virtual memory exhaustion. Virtual memory exhaustion may be detected by calling GetLastRtError() immediately after the malloc() failure. If physical memory is exhausted, the value is E_MEM, is virtual memory is exhausted the value is E_VMEM.


Versions Defined in Include Link to
INtime 3.0 intime/rt/include/stdlib.h stdlib.h clib.lib

See Also

calloc, free, realloc, About heap object management functions, C/C++ Runtime heap, Memory pools