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