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