Standard library module

Contents

Butano's standard library replacement.

The biggest difference against C++'s standard library is the usage of asserts instead of exceptions and that it avoids the heap when possible.

Modules

module Containers
module Utilities
module Functional

Files

file bn_algorithm.h
file bn_bit.h
file bn_compare.h
file bn_cstdlib.h
file bn_cstring.h
file bn_iterator.h
file bn_limits.h
file bn_type_traits.h

Functions

auto malloc(int bytes) -> void*
Allocates size bytes of uninitialized storage in the EWRAM.
void free(void* ptr)
Deallocates the space previously allocated by bn::malloc.
void memcpy(void* destination, const void* source, int bytes)
Copies the given bytes from the object pointed to by source to the object pointed to by destination.
void memset(void* destination, uint8_t value, int bytes)
Copies the given value into each of the first given bytes of the object pointed to by destination.
void memclear(void* destination, int bytes)
Copies the value 0 into each of the first given bytes of the object pointed to by destination.

Function documentation

void* malloc(int bytes)

Allocates size bytes of uninitialized storage in the EWRAM.

Parameters
bytes Number of bytes to allocate.
Returns The pointer to the beginning of the allocated memory if it could be allocated; nullptr otherwise.

void free(void* ptr)

Deallocates the space previously allocated by bn::malloc.

Parameters
ptr Pointer to the memory to deallocate.

If ptr is a null pointer, the function does nothing.

If ptr was not previously allocated by bn::malloc, the behavior is undefined.

void memcpy(void* destination, const void* source, int bytes)

Copies the given bytes from the object pointed to by source to the object pointed to by destination.

Parameters
destination Pointer to the memory location to copy to.
source Pointer to the memory location to copy from.
bytes Number of bytes to copy.

void memset(void* destination, uint8_t value, int bytes)

Copies the given value into each of the first given bytes of the object pointed to by destination.

Parameters
destination Pointer to the object to fill.
value Fill byte.
bytes Number of bytes to fill.

void memclear(void* destination, int bytes)

Copies the value 0 into each of the first given bytes of the object pointed to by destination.

Parameters
destination Pointer to the object to clear.
bytes Number of bytes to clear.