]>
Commit | Line | Data |
---|---|---|
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 |
10 | struct 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 | ||
22 | struct 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 | ||
30 | struct strbuf_child_entry { | |
31 | uint8_t c; | |
32 | struct strbuf_node *child; | |
33 | }; | |
34 | ||
35 | struct strbuf *strbuf_new(void); | |
36 | ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len); | |
37 | void strbuf_complete(struct strbuf *str); | |
38 | void strbuf_cleanup(struct strbuf *str); | |
b012e921 | 39 | DEFINE_TRIVIAL_CLEANUP_FUNC(struct strbuf*, strbuf_cleanup); |