#include #include #include #ifndef __RR_BAREMETAL #include /// @brief An allocator for the sole purpose of preventing warnings because of an unused /// parameter in the standard allocator proxying functions. rr_generic_allocator_s *rr_last_used_proxy_allocator; void * rr_proxy_malloc(rr_generic_allocator_s *allocator, usz_t num_bytes) { rr_last_used_proxy_allocator = allocator; return malloc(num_bytes); } void rr_proxy_free(rr_generic_allocator_s *allocator, void *block) { rr_last_used_proxy_allocator = allocator; free(block); } rr_generic_allocator_s rr_provide_stdlib_allocator() { rr_generic_allocator_s allocator; allocator.fn_alloc = &rr_proxy_malloc; allocator.fn_free = &rr_proxy_free; allocator.specifics = NULL; allocator.fn_destruct = NULL; return allocator; } #endif // __RR_BAREMETAL rr_generic_arena_s rr_provide_arena(rr_generic_allocator_s *allocator, usz_t len_allocation) { return rr_new_arena(allocator, len_allocation); } rr_generic_pool_s rr_provide_dynamic_pool(rr_generic_allocator_s *allocator, usz_t item_size, usz_t capacity) { return rr_new_dynamic_pool(allocator, item_size, capacity); } rr_generic_pool_s rr_provide_static_pool(rr_generic_allocator_s *allocator, usz_t item_size, usz_t capacity) { return rr_new_dynamic_pool(allocator, item_size, capacity); } rr_generic_arena_s rr_provide_arena_from_malloc(usz_t len_allocation) { rr_generic_allocator_s allocator = rr_provide_stdlib_allocator(); return rr_new_arena(&allocator, len_allocation); } rr_generic_pool_s rr_provide_dynamic_pool_from_malloc(usz_t item_size, usz_t capacity) { rr_generic_allocator_s allocator = rr_provide_stdlib_allocator(); return rr_new_dynamic_pool(&allocator, item_size, capacity); } rr_generic_pool_s rr_provide_static_pool_from_malloc(usz_t item_size, usz_t capacity) { rr_generic_allocator_s allocator = rr_provide_stdlib_allocator(); return rr_new_static_pool(&allocator, item_size, capacity); }