Melee Modding Library  2.0.0
A C library for modding Super Smash Bros Melee
Functions
system.h File Reference

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...
 

Detailed Description

System level functions.

Function Documentation

void initHeap ( void *  lo,
void *  hi 
)

Initialize heap

Initializes the heap that is used for all calls to malloc, calloc, realloc, and free.

Parameters
lo- lower address of the heap
hi- upper address of the heap
Returns
none
size_t getHeapSize ( )

Get the size of the heap

Returns the size (in bytes) of the heap that was allocated with initHeap.

Returns
size of the heap in bytes.
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.

Parameters
limit- address that marks the top of the game heap.
Returns
none
Note
0x81780000 seems to be reasonably stable - recommended that values less than this are not used
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.

Parameters
size- Size of memory block in bytes.
Returns
On success, a pointer to the memory block allocated by the function. If the function failed to allocate the requested block of memory, a null pointer is returned.
See also
http://www.cplusplus.com/reference/cstdlib/malloc/
void* calloc ( size_t  num,
size_t  size 
)

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.

Parameters
num- Number of elements to allocate
size- Size of each element
Returns
On success, a pointer to the memory block allocated by the function. If the function failed to allocate the requested block of memory, a null pointer is returned.
See also
http://www.cplusplus.com/reference/cstdlib/calloc/
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.

Parameters
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.
Returns
A pointer to the reallocated memory block, which may be either the same as 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).
See also
http://www.cplusplus.com/reference/cstdlib/realloc/
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.

Parameters
ptr- Pointer to a memory block previously allocated with malloc or realloc.
Returns
none
See also
http://www.cplusplus.com/reference/cstdlib/free/