Starboard Module Reference: memory.h

  • Provides functions for managing memory, including allocation, reallocation, and deallocation, with both checked and unchecked variants.

  • Offers memory mapping functionalities with configurable protection flags like read, write, and execute.

  • Encourages utilizing SbMemoryAllocate and SbMemoryDeallocate for memory management to enable Starboard's memory tracking capabilities.

  • "Unchecked" and "Free" functions should be implemented by porters but not called directly, as they are wrapped by Starboard for accounting purposes.

Defines functions for memory allocation, alignment, copying, and comparing.

Porters

All of the "Unchecked" and "Free" functions must be implemented, but they should not be called directly. The Starboard platform wraps them with extra accounting under certain circumstances.

Porters and Application Developers

Nobody should call the "Checked", "Unchecked" or "Free" functions directly because that evades Starboard's memory tracking. In both port implementations and Starboard client application code, you should always call SbMemoryAllocate and SbMemoryDeallocate rather than SbMemoryAllocateUnchecked and SbMemoryFree.

  • The "checked" functions are SbMemoryAllocateChecked(), SbMemoryReallocateChecked(), and SbMemoryAllocateAlignedChecked().

  • The "unchecked" functions are SbMemoryAllocateUnchecked(), SbMemoryReallocateUnchecked(), and SbMemoryAllocateAlignedUnchecked().

  • The "free" functions are SbMemoryFree() and SbMemoryFreeAligned().

Enums

SbMemoryMapFlags

The bitwise OR of these flags should be passed to SbMemoryMap to indicate how the mapped memory can be used.

Values

  • kSbMemoryMapProtectReserved

    No flags set: Reserves virtual address space. SbMemoryProtect() can later make it accessible.

  • kSbMemoryMapProtectRead

  • kSbMemoryMapProtectWrite

  • kSbMemoryMapProtectExec

  • kSbMemoryMapProtectReadWrite