Debian Codegraph @

lib/cgraph/agstrcanon.h

raw
1 /// @file
2 /// @brief Helpers for dealing with `agstrcanon`
3
4 #pragma once
5
6 #include <stddef.h>
7 #include <string.h>
8 #include <util/alloc.h>
9
10 /// how many bytes are needed to canonicalize the given string
11 static inline size_t agstrcanon_bytes(const char *str) {
12 return 2 * strlen(str) + 2;
13 }
14
15 /// get a buffer suitable for passing into `agstrcanon`
16 static inline char *agstrcanon_buffer(const char *str) {
17 return gv_alloc(agstrcanon_bytes(str));
18 }