]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/mempool.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / basic / mempool.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
b3dcf58e
MS
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 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
24#include <stddef.h>
25
26struct pool;
27
28struct mempool {
29 struct pool *first_pool;
30 void *freelist;
31 size_t tile_size;
32 unsigned at_least;
33};
34
35void* mempool_alloc_tile(struct mempool *mp);
52fc5ce3 36void* mempool_alloc0_tile(struct mempool *mp);
b3dcf58e
MS
37void mempool_free_tile(struct mempool *mp, void *p);
38
39#define DEFINE_MEMPOOL(pool_name, tile_type, alloc_at_least) \
dd422d1e 40static struct mempool pool_name = { \
b3dcf58e
MS
41 .tile_size = sizeof(tile_type), \
42 .at_least = alloc_at_least, \
43}
44
45
46#ifdef VALGRIND
47void mempool_drop(struct mempool *mp);
48#endif