]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/bitmap.h
util: move string_is_safe() to string-util.[ch]
[thirdparty/systemd.git] / src / basic / bitmap.h
CommitLineData
5ffa42cb
TG
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 2015 Tom Gundersen
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 "macro.h"
cb57dd41 25#include "hashmap.h"
5ffa42cb
TG
26
27typedef struct Bitmap Bitmap;
28
29Bitmap *bitmap_new(void);
30
31void bitmap_free(Bitmap *b);
32
33int bitmap_ensure_allocated(Bitmap **b);
34
35int bitmap_set(Bitmap *b, unsigned n);
36void bitmap_unset(Bitmap *b, unsigned n);
37bool bitmap_isset(Bitmap *b, unsigned n);
38bool bitmap_isclear(Bitmap *b);
39void bitmap_clear(Bitmap *b);
40
cb57dd41 41bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n);
5ffa42cb
TG
42
43bool bitmap_equal(Bitmap *a, Bitmap *b);
44
cb57dd41
TG
45#define BITMAP_FOREACH(n, b, i) \
46 for ((i).idx = 0; bitmap_iterate((b), &(i), (unsigned*)&(n)); )
5ffa42cb
TG
47
48DEFINE_TRIVIAL_CLEANUP_FUNC(Bitmap*, bitmap_free);
49
50#define _cleanup_bitmap_free_ _cleanup_(bitmap_freep)