KallistiOS
##version##
|
Standard C Malloc functionality. More...
Go to the source code of this file.
Data Structures | |
struct | mallinfo |
ANSI C functions. More... | |
Macros | |
#define | M_MXFAST 1 |
#define | DEFAULT_MXFAST 64 |
#define | M_TRIM_THRESHOLD -1 |
#define | DEFAULT_TRIM_THRESHOLD (256*1024) |
#define | M_TOP_PAD -2 |
#define | DEFAULT_TOP_PAD 0 |
#define | M_MMAP_THRESHOLD -3 |
#define | DEFAULT_MMAP_THRESHOLD (256*1024) |
#define | M_MMAP_MAX -4 |
#define | DEFAULT_MMAP_MAX 65536 |
Functions | |
void * | malloc (size_t size) |
allocate memory More... | |
void * | calloc (size_t nmemb, size_t size) |
allocate memory on the heap and initialize it to 0 More... | |
void | free (void *ptr) |
releases memory that was previous allocated More... | |
void * | realloc (void *ptr, size_t size) |
changes the size of previously allocated memory More... | |
void * | memalign (size_t alignment, size_t size) |
allocate memory aligned memory More... | |
void * | valloc (size_t size) |
allocates memory aligned to the system page size More... | |
struct mallinfo | mallinfo () |
Sets tunable parameters for malloc related options. More... | |
int | mallopt (int, int) |
void | malloc_stats () |
Debug function. More... | |
int | malloc_irq_safe () |
KOS specfic calls. More... | |
int | mem_check_block (void *p) |
Only available with KM_DBG. More... | |
int | mem_check_all () |
Only available with KM_DBG. More... | |
Standard C Malloc functionality.
This implements standard C heap allocation, deallocation, and stats.
#define DEFAULT_MMAP_MAX 65536 |
#define DEFAULT_MMAP_THRESHOLD (256*1024) |
#define DEFAULT_MXFAST 64 |
#define DEFAULT_TOP_PAD 0 |
#define DEFAULT_TRIM_THRESHOLD (256*1024) |
#define M_MMAP_MAX -4 |
#define M_MMAP_THRESHOLD -3 |
#define M_MXFAST 1 |
#define M_TOP_PAD -2 |
#define M_TRIM_THRESHOLD -1 |
void* calloc | ( | size_t | nmemb, |
size_t | size | ||
) |
allocate memory on the heap and initialize it to 0
This allocates a chunk of memory of size * nmemb. In otherwords, an array with nmemb elements of size or size[nmemb].
nmemb | is the amount of elements |
size | the size of each element |
void free | ( | void * | ptr | ) |
releases memory that was previous allocated
frees the memory space that had previously been allocated by malloc or calloc.
ptr | is a pointer to the address of allocated ram |
void* malloc | ( | size_t | size | ) |
allocate memory
This allocates the specified size of bytes onto the heap. This memory is not freed automatically if the returned pointer goes out of scope. Thus you must call free to reclaim the used space when finished.
size | is the size in bytes to allocate |
int malloc_irq_safe | ( | ) |
KOS specfic calls.
void malloc_stats | ( | ) |
Debug function.
int mallopt | ( | int | , |
int | |||
) |
int mem_check_all | ( | ) |
Only available with KM_DBG.
int mem_check_block | ( | void * | p | ) |
Only available with KM_DBG.
void* memalign | ( | size_t | alignment, |
size_t | size | ||
) |
allocate memory aligned memory
Memory of size is allocated with the address being a multiple of alignment
alignment | a multiple of two that the memory address will be aligned to |
size | the size of the memory to allocate |
void* realloc | ( | void * | ptr, |
size_t | size | ||
) |
changes the size of previously allocated memory
The size of ptr is changed to size. If data has already been placed in the memory area at that location, it's preserved up to size. If size is larger then the previously allocated memory, the new area will be unititialized.
ptr | the address pointer that's been previously returned by malloc/calloc |
size | the new size to give to the memory |
void* valloc | ( | size_t | size | ) |
allocates memory aligned to the system page size
Memory is allocated of size and is aligned to the system page size. This ends up basically being: memolign(PAGESIZE, size)
size | the size of the memory to allocate |