diff options
author | David Robillard <d@drobilla.net> | 2020-08-12 15:23:49 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-08 23:23:06 -0500 |
commit | bf01cef66e561ea0cd2ad0babf08194b00f84b77 (patch) | |
tree | 67bca98c4769a3806e715cedff5bcfabb816e367 | |
parent | 7d69e5aef5203e66d5730ccf8aed1d7596ddcb2e (diff) | |
download | serd-bf01cef66e561ea0cd2ad0babf08194b00f84b77.tar.gz serd-bf01cef66e561ea0cd2ad0babf08194b00f84b77.tar.bz2 serd-bf01cef66e561ea0cd2ad0babf08194b00f84b77.zip |
Move local URI utility functions
-rw-r--r-- | src/node.c | 56 |
1 files changed, 28 insertions, 28 deletions
@@ -87,6 +87,34 @@ serd_node_check_padding(const SerdNode* node) #endif } +static size_t +serd_uri_string_length(const SerdURIView* uri) +{ + size_t len = uri->path_prefix.len; + +#define ADD_LEN(field, n_delims) \ + if ((field).len) { \ + len += (field).len + (n_delims); \ + } + + ADD_LEN(uri->path, 1) // + possible leading `/' + ADD_LEN(uri->scheme, 1) // + trailing `:' + ADD_LEN(uri->authority, 2) // + leading `//' + ADD_LEN(uri->query, 1) // + leading `?' + ADD_LEN(uri->fragment, 1) // + leading `#' + + return len + 2; // + 2 for authority `//' +} + +static size_t +string_sink(const void* buf, size_t size, size_t nmemb, void* stream) +{ + char** ptr = (char**)stream; + memcpy(*ptr, buf, size * nmemb); + *ptr += size * nmemb; + return nmemb; +} + size_t serd_node_total_size(const SerdNode* node) { @@ -369,34 +397,6 @@ serd_node_equals(const SerdNode* a, const SerdNode* b) return serd_node_total_size(b) == a_size && !memcmp(a, b, a_size); } -static size_t -serd_uri_string_length(const SerdURIView* uri) -{ - size_t len = uri->path_prefix.len; - -#define ADD_LEN(field, n_delims) \ - if ((field).len) { \ - len += (field).len + (n_delims); \ - } - - ADD_LEN(uri->path, 1) // + possible leading `/' - ADD_LEN(uri->scheme, 1) // + trailing `:' - ADD_LEN(uri->authority, 2) // + leading `//' - ADD_LEN(uri->query, 1) // + leading `?' - ADD_LEN(uri->fragment, 1) // + leading `#' - - return len + 2; // + 2 for authority `//' -} - -static size_t -string_sink(const void* buf, size_t size, size_t nmemb, void* stream) -{ - char** ptr = (char**)stream; - memcpy(*ptr, buf, size * nmemb); - *ptr += size * nmemb; - return nmemb; -} - SerdNode* serd_new_uri(const SerdStringView str) { |