| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include "basic-forward.h" |
| 5 |
|
| 6 |
struct pool; |
| 7 |
|
| 8 |
struct mempool { |
| 9 |
struct pool *first_pool; |
| 10 |
void *freelist; |
| 11 |
size_t tile_size; |
| 12 |
size_t at_least; |
| 13 |
}; |
| 14 |
|
| 15 |
void* mempool_alloc_tile(struct mempool *mp); |
| 16 |
void* mempool_alloc0_tile(struct mempool *mp); |
| 17 |
void* mempool_free_tile(struct mempool *mp, void *p); |
| 18 |
|
| 19 |
#define DEFINE_MEMPOOL(pool_name, tile_type, alloc_at_least) \ |
| 20 |
static struct mempool pool_name = { \ |
| 21 |
.tile_size = sizeof(tile_type), \ |
| 22 |
.at_least = alloc_at_least, \ |
| 23 |
} |
| 24 |
|
| 25 |
bool mempool_enabled(void) _weak_ _pure_; |
| 26 |
|
| 27 |
void mempool_trim(struct mempool *mp); |