]> git.proxmox.com Git - systemd.git/blame - src/basic/strbuf.h
New upstream version 240
[systemd.git] / src / basic / strbuf.h
CommitLineData
52ad194e 1/* SPDX-License-Identifier: LGPL-2.1+ */
663996b3
MS
2#pragma once
3
4c89c718 4#include <stddef.h>
663996b3 5#include <stdint.h>
4c89c718 6#include <sys/types.h>
663996b3 7
b012e921
MB
8#include "macro.h"
9
663996b3
MS
10struct strbuf {
11 char *buf;
12 size_t len;
13 struct strbuf_node *root;
14
15 size_t nodes_count;
16 size_t in_count;
17 size_t in_len;
18 size_t dedup_len;
19 size_t dedup_count;
20};
21
22struct strbuf_node {
23 size_t value_off;
24 size_t value_len;
25
26 struct strbuf_child_entry *children;
27 uint8_t children_count;
28};
29
30struct strbuf_child_entry {
31 uint8_t c;
32 struct strbuf_node *child;
33};
34
35struct strbuf *strbuf_new(void);
36ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len);
37void strbuf_complete(struct strbuf *str);
38void strbuf_cleanup(struct strbuf *str);
b012e921 39DEFINE_TRIVIAL_CLEANUP_FUNC(struct strbuf*, strbuf_cleanup);