#ifndef MEM_FRAMER_H #define MEM_FRAMER_H #include #include "allocator.h" typedef struct mem_framer_freed { struct mem_framer_freed *next; } MemFramerFreed; /* Allocator for frames: aligned regions of memory of same size */ typedef struct mem_framer { MemAllocator allocator; /* The next frame to be given off to the caller in case the freelist is empty */ usize next; /* The end of the region covered by the memory allocator */ usize end; /* The address of the last frame that has been added in the freelist NOTE: the freelist is a singly-linked list comprising all frames that have been previously allocated and then freed */ MemFramerFreed *free; /* The size of a frame. This value also defines the alignment that the frames must respect */ uint blksz; } MemFramer; MemFramer *mem_framer_install(void *addr, usize end, uint blksz); void *mem_framer_alloc(MemAllocator *self, usize n); void mem_framer_free(MemAllocator *self, void *ptr); #endif