Melee Modding Library
2.0.0
A C library for modding Super Smash Bros Melee
|
System level functions. More...
#include "gctypes.h"
Go to the source code of this file.
Functions | |
void | initHeap (void *lo, void *hi) |
size_t | getHeapSize () |
void | limitGameMemory (void *limit) |
limit size of game heap More... | |
void * | malloc (size_t size) |
Allocate memory block. More... | |
void * | calloc (size_t num, size_t size) |
Allocate and zero-initialize array. More... | |
void * | realloc (void *ptr, size_t size) |
Reallocate memory block. More... | |
void | free (void *ptr) |
Deallocate memory block. More... | |
System level functions.
void initHeap | ( | void * | lo, |
void * | hi | ||
) |
Initialize heap
Initializes the heap that is used for all calls to malloc
, calloc
, realloc
, and free
.
lo | - lower address of the heap |
hi | - upper address of the heap |
size_t getHeapSize | ( | ) |
Get the size of the heap
Returns the size (in bytes) of the heap that was allocated with initHeap
.
void limitGameMemory | ( | void * | limit | ) |
limit size of game heap
Restricts the size of the heap that the game can use. The game will not touch any memory between limit
and 0x817f8ab0. This is not guaranteed to be stable.
limit | - address that marks the top of the game heap. |
void* malloc | ( | size_t | size | ) |
Allocate memory block.
Allocates a block of size
bytes of memory, returning a pointer to the beginning of the block. The content of the newly allocated block of memory is not initialized. If malloc
fails to allocate the memory, a NULL
pointer is returned.
size | - Size of memory block in bytes. |
Allocate and zero-initialize array.
Allocates a block of memory for an array of num
elements, each of them size
bytes long, and initializes all its bits to zero.
The effective result is the allocation of a zero-initialized memory block of (num*size) bytes.
num | - Number of elements to allocate |
size | - Size of each element |
void* realloc | ( | void * | ptr, |
size_t | size | ||
) |
Reallocate memory block.
Changes the size of the memory block pointed to by ptr
. The function may move the memory block to a new location (whose address is returned by the function). The content of the memory block is preserved up to the lesser of the new and old sizes, even if the block is moved to a new location.
ptr | - Pointer to a memory block previously allocated with malloc or realloc . Alternatively, this can be a null pointer, in which case a new block is allocated (as if malloc was called). |
size | - New size for the memory block, in bytes. |
ptr
or a new location. A null-pointer indicates either that size
was zero (an thus ptr was deallocated), or that the function did not allocate storage (and thus the block pointed by ptr
was not modified).void free | ( | void * | ptr | ) |
Deallocate memory block.
A block of memory previously allocated by a call to malloc
or realloc
is deallocated, making it available again for further allocations.
ptr | - Pointer to a memory block previously allocated with malloc or realloc . |