# malloc

Allocates memory.

### Synopsis

`void *malloc( int32 size )`

### Description

This procedure allocates a memory block. It is identical to the `malloc()` procedure in the standard C library. The memory is guaranteed only to be memory that is accessible to the CPU; you cannot specify the memory type (such as VRAM), alignment (such as a memory block that begins on a page boundary), or any other memory characteristics.

Note: You should only use `malloc()` when porting existing C programs to Portfolio. If you are writing programs specifically for Portfolio, use `AllocMem()`, which allows you to specify the type of memory to allocate, such as VRAM or memory that begins on a page boundary.

### Arguments

size
  Size of the memory block to allocate, in bytes.

### Return Value

The procedure returns a pointer to the memory that was allocated or NULL if the memory couldn't be allocated.

### Implementation

Convenience call implemented in clib.lib V20.

### Associated Files

stdlib.h
  ANSI C Prototype

clib.lib
  ARM Link Library

### Notes

You can enable memory debugging in your application by compiling your entire project with the MEMDEBUG value defined on the compiler's command-line. Refer to the `CreateMemDebug()` function for more details.

### See Also

``AllocMem`(), AvailMem(), free()`

#