+/rtos
git clone https://git.julia.blue/+/rtos
4853344
master
1#pragma once 2#include <stdbool.h> 3#include <stdint.h> 4 5typedef struct HeapNode { 6struct HeapNode * next ; 7uint16_t size ; 8}HeapNode ; 9 10void heap_init (void ); 11 12// Allocate uninitionalized heap space. Returns NULL if OOM. 13void * malloc (uint32_t size ); 14 15// Allocate zero-initialized heap space. Returns NULL if OOM. 16void * calloc (uint32_t size ); 17 18// Change size of allocation (may move data). Returns NULL if OOM. 19// If the allocation passed is NULL, acts like malloc(size) 20void * realloc (void * allocation ,uint32_t size ); 21 22// Deallocate 23void free (void * allocation ); 24 25// Print usage statistics about the heap 26void heap_stats (void ); 27 28// Get number of bytes available for allocation in heap 29uint32_t heap_get_space (void ); 30 31// Get the size of the largest possible allocation that can currently be made 32uint32_t heap_get_max (void ); 33 34// Helper for accessing heap nodes 35HeapNode * heap_node_from_alloc (void * alloc );