1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 #pragma once 3 4 #include <stdbool.h> 5 #include <stddef.h> 6 7 struct pool; 8 9 struct mempool { 10 struct pool *first_pool; 11 void *freelist; 12 size_t tile_size; 13 unsigned at_least; 14 }; 15 16 void* mempool_alloc_tile(struct mempool *mp); 17 void* mempool_alloc0_tile(struct mempool *mp); 18 void mempool_free_tile(struct mempool *mp, void *p); 19 20 #define DEFINE_MEMPOOL(pool_name, tile_type, alloc_at_least) \ 21 static struct mempool pool_name = { \ 22 .tile_size = sizeof(tile_type), \ 23 .at_least = alloc_at_least, \ 24 } 25 26 extern const bool mempool_use_allowed; 27 bool mempool_enabled(void); 28 29 #if VALGRIND 30 void mempool_drop(struct mempool *mp); 31 #endif 32