#ifndef FACTORIO_GUEST_HEAP_H #define FACTORIO_GUEST_HEAP_H #include #include /* A bounded, per-run arena of guest offsets. No native pointers enter guest RAM. * Allocations are 16-byte aligned and uninitialized; reset discards the arena. * This does not implement C++ destruction, free, or exception unwinding. */ typedef struct { uint8_t *memory; uint64_t memory_size, begin, cursor, end; unsigned allocations; } FactorioGuestHeap; int factorio_guest_heap_init(FactorioGuestHeap *heap, uint8_t *memory, uint64_t memory_size, uint64_t begin, uint64_t end); /* 0 success, 1 exhausted, 2 invalid. Output and heap unchanged on failure. */ int factorio_guest_heap_allocate(FactorioGuestHeap *heap, uint64_t size, uint64_t *out); #endif