libtransistor
A userland library for the Nintendo Switch
|
Page allocation functions. More...
Go to the source code of this file.
Functions | |
void * | alloc_pages (size_t min, size_t max, size_t *actual) |
Allocates memory pages. More... | |
bool | free_pages (void *pages) |
Frees memory pages returned from alloc_pages. More... | |
Page allocation functions.
void* alloc_pages | ( | size_t | min, |
size_t | max, | ||
size_t * | actual | ||
) |
Allocates memory pages.
This will allocate a page-aligned region of memory that is at least min bytes long and no more than max bytes long. The actual length of the memory region is written to actual.
If min == max, you are guaranteed to either get that much memory or no memory at all, and can pass NULL in actual.
The pointer returned by this function should be passed to free_pages before the program terminates.
If alloc_pages has been set in loader_config, that allocator will be used instead of the application's self-hosted one.
min | Lower bound on how much memory to allocate (in bytes) |
max | Upper bound on how much memory to allocate (in bytes) |
actual | Output for how much memory was actually allocated. Can be NULL. |
bool free_pages | ( | void * | pages | ) |
Frees memory pages returned from alloc_pages.
Frees a region of memory returned from alloc_pages. The memory should be RW-, type 5 (HEAP), and have no attributes set.
If alloc_pages has been set in loader_config, that allocator will be used instead of the application's self-hosted one.
pages | Pointer returned by alloc_pages |