|
Deki 0.19.0
Modular C++ 2D engine for embedded displays and desktop
|
Memory provider over the C heap (malloc/free), for any host with a normal C library heap: the editor, desktop and simulator builds, tests. More...
#include <deki/providers/HostMemoryProvider.h>
Inherits Deki::IMemoryProvider.
Public Member Functions | |
| HostMemoryProvider ()=default | |
| ~HostMemoryProvider () override=default | |
| bool | Initialize () override |
| Returns false on failure. | |
| void | Shutdown () override |
| bool | Serves (Memory::Region region) const override |
| True when the board can place memory in region. | |
| void * | Allocate (Memory::Region region, size_t bytes, bool needsDma) override |
| Allocates bytes from region, or returns nullptr, including for a region the board does not serve; it never substitutes another region. | |
| void | Free (Memory::Region region, void *ptr) override |
| Frees a block from region. | |
| size_t | GetAvailable (Memory::Region region) const override |
| Bytes still free in region, or 0 when the platform cannot measure it. | |
| size_t | GetRawBlockSize (void *ptr) const override |
| Usable size of a block from AllocateRaw, or 0 when the platform cannot say. | |
| Public Member Functions inherited from Deki::IMemoryProvider | |
| virtual | ~IMemoryProvider ()=default |
| virtual void * | AllocateRaw (size_t size) |
| Allocates size bytes, or returns nullptr. | |
| virtual void | FreeRaw (void *ptr) |
| Frees a block from AllocateRaw. Override both or neither. | |
Memory provider over the C heap (malloc/free), for any host with a normal C library heap: the editor, desktop and simulator builds, tests.
|
default |
|
overridedefault |
|
inlineoverridevirtual |
Returns false on failure.
Implements Deki::IMemoryProvider.
|
inlineoverridevirtual |
Implements Deki::IMemoryProvider.
|
inlineoverridevirtual |
True when the board can place memory in region.
A platform with one heap answers true for every region it can satisfy: where all memory is equally fast, "external" without PSRAM is the same place as "internal". Memory asks once at startup to report what the board has.
Implements Deki::IMemoryProvider.
|
inlineoverridevirtual |
Allocates bytes from region, or returns nullptr, including for a region the board does not serve; it never substitutes another region.
needsDma means a DMA engine must be able to read the block, in any region: a framebuffer must be reachable in internal RAM or PSRAM alike.
One entry point, not a virtual per region, because packages can define new regions (such as "rtc") without an engine release. A provider switches on region.id, a compile-time constant, and returns nullptr for any it does not know.
Implements Deki::IMemoryProvider.
|
inlineoverridevirtual |
Frees a block from region.
The region comes from the allocation's own header, so callers never pass it themselves.
Implements Deki::IMemoryProvider.
|
inlineoverridevirtual |
Bytes still free in region, or 0 when the platform cannot measure it.
It appears in the startup line and in every out-of-memory message, so a provider returning 0 should say in a comment that 0 means "unknown", not "exhausted".
Implements Deki::IMemoryProvider.
|
inlineoverridevirtual |
Usable size of a block from AllocateRaw, or 0 when the platform cannot say.
There is no header, so the heap is asked (heap_caps_get_allocated_size on ESP-IDF, _msize on Windows). Only keeps the byte total right on free; 0 costs accuracy in Memory::LogStats and nothing else.
Reimplemented from Deki::IMemoryProvider.