]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/strbuf.h
Turn VALGRIND variable into a meson configuration switch
[thirdparty/systemd.git] / src / basic / strbuf.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
955bd501
KS
2#pragma once
3
4/***
5 This file is part of systemd.
6
1298001e 7 Copyright 2012 Kay Sievers <kay@vrfy.org>
955bd501
KS
8***/
9
11c3a366 10#include <stddef.h>
955bd501 11#include <stdint.h>
11c3a366 12#include <sys/types.h>
955bd501 13
f201daec
ZJS
14#include "macro.h"
15
955bd501
KS
16struct strbuf {
17 char *buf;
18 size_t len;
19 struct strbuf_node *root;
20
21 size_t nodes_count;
22 size_t in_count;
23 size_t in_len;
24 size_t dedup_len;
25 size_t dedup_count;
26};
27
28struct strbuf_node {
29 size_t value_off;
30 size_t value_len;
31
32 struct strbuf_child_entry *children;
33 uint8_t children_count;
34};
35
36struct strbuf_child_entry {
37 uint8_t c;
38 struct strbuf_node *child;
39};
40
41struct strbuf *strbuf_new(void);
42ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len);
43void strbuf_complete(struct strbuf *str);
44void strbuf_cleanup(struct strbuf *str);
f201daec 45DEFINE_TRIVIAL_CLEANUP_FUNC(struct strbuf*, strbuf_cleanup);