]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/mempool.h
Merge pull request #7388 from keszybz/doc-tweak
[thirdparty/systemd.git] / src / basic / mempool.h
1 #pragma once
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2011-2014 Lennart Poettering
7 Copyright 2014 Michal Schmidt
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #include <stddef.h>
24
25 struct pool;
26
27 struct mempool {
28 struct pool *first_pool;
29 void *freelist;
30 size_t tile_size;
31 unsigned at_least;
32 };
33
34 void* mempool_alloc_tile(struct mempool *mp);
35 void* mempool_alloc0_tile(struct mempool *mp);
36 void mempool_free_tile(struct mempool *mp, void *p);
37
38 #define DEFINE_MEMPOOL(pool_name, tile_type, alloc_at_least) \
39 static struct mempool pool_name = { \
40 .tile_size = sizeof(tile_type), \
41 .at_least = alloc_at_least, \
42 }
43
44
45 #ifdef VALGRIND
46 void mempool_drop(struct mempool *mp);
47 #endif