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