aboutsummaryrefslogtreecommitdiffstats
path: root/src/node.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-06-30 16:56:46 -0400
committerDavid Robillard <d@drobilla.net>2021-06-30 16:56:46 -0400
commit9d5b09ab38e36d993627a6fd3de3e07b7bcdd5ad (patch)
tree63a9d7ae04142a80b9fb6fa01966ca10d72f8742 /src/node.c
parentc1cae48eb3851239817c8cda5a8266815fb3173e (diff)
downloadserd-9d5b09ab38e36d993627a6fd3de3e07b7bcdd5ad.tar.gz
serd-9d5b09ab38e36d993627a6fd3de3e07b7bcdd5ad.tar.bz2
serd-9d5b09ab38e36d993627a6fd3de3e07b7bcdd5ad.zip
Move local URI utility functions
Diffstat (limited to 'src/node.c')
-rw-r--r--src/node.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/node.c b/src/node.c
index 5629565a..3b125d66 100644
--- a/src/node.c
+++ b/src/node.c
@@ -39,6 +39,34 @@
# endif
#endif
+static size_t
+serd_uri_string_length(const SerdURI* const 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* const buf, const size_t len, void* const stream)
+{
+ uint8_t** ptr = (uint8_t**)stream;
+ memcpy(*ptr, buf, len);
+ *ptr += len;
+ return len;
+}
+
SerdNode
serd_node_from_string(const SerdType type, const uint8_t* const str)
{
@@ -94,34 +122,6 @@ serd_node_equals(const SerdNode* const a, const SerdNode* const b)
!memcmp((const char*)a->buf, (const char*)b->buf, a->n_bytes + 1)));
}
-static size_t
-serd_uri_string_length(const SerdURI* const 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* const buf, const size_t len, void* const stream)
-{
- uint8_t** ptr = (uint8_t**)stream;
- memcpy(*ptr, buf, len);
- *ptr += len;
- return len;
-}
-
SerdNode
serd_node_new_uri_from_node(const SerdNode* const uri_node,
const SerdURI* const base,