]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/mempool.h
dad4a4f9ccb565a37695041b903a387a1e691570
[thirdparty/systemd.git] / src / basic / mempool.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright 2011-2014 Lennart Poettering
6 Copyright 2014 Michal Schmidt
7 ***/
8
9 #include <stddef.h>
10
11 struct pool;
12
13 struct mempool {
14 struct pool *first_pool;
15 void *freelist;
16 size_t tile_size;
17 unsigned at_least;
18 };
19
20 void* mempool_alloc_tile(struct mempool *mp);
21 void* mempool_alloc0_tile(struct mempool *mp);
22 void mempool_free_tile(struct mempool *mp, void *p);
23
24 #define DEFINE_MEMPOOL(pool_name, tile_type, alloc_at_least) \
25 static struct mempool pool_name = { \
26 .tile_size = sizeof(tile_type), \
27 .at_least = alloc_at_least, \
28 }
29
30 #if VALGRIND
31 void mempool_drop(struct mempool *mp);
32 #endif