diff options
author | David Robillard <d@drobilla.net> | 2020-08-12 15:23:49 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-27 13:13:59 +0100 |
commit | dc9d3e98500aed29aba54198fa3c2c254d296325 (patch) | |
tree | 1c01ec4e02e46aa580bbe97d4a1ba498c6ed0e04 | |
parent | 57a44e8c20d3b887b56e3774b15beefdba78db7e (diff) | |
download | serd-dc9d3e98500aed29aba54198fa3c2c254d296325.tar.gz serd-dc9d3e98500aed29aba54198fa3c2c254d296325.tar.bz2 serd-dc9d3e98500aed29aba54198fa3c2c254d296325.zip |
Move local URI utility functions
-rw-r--r-- | src/node.c | 52 |
1 files changed, 26 insertions, 26 deletions
@@ -89,6 +89,32 @@ serd_node_check_padding(const SerdNode* node) #endif } +static size_t +serd_uri_string_length(const SerdURI* uri) +{ + size_t len = uri->path_base.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) { @@ -388,32 +414,6 @@ serd_node_compare(const SerdNode* a, const SerdNode* b) serd_node_maybe_get_meta_c(b)); } -static size_t -serd_uri_string_length(const SerdURI* uri) -{ - size_t len = uri->path_base.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_resolved_uri(const char* str, const SerdNode* base) { |