aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--serd/serd.h2
-rw-r--r--src/reader.c4
-rw-r--r--src/serd_internal.h22
3 files changed, 15 insertions, 13 deletions
diff --git a/serd/serd.h b/serd/serd.h
index 7580207d..3b0fe41a 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -547,7 +547,7 @@ serd_read_state_expand(SerdReadState* state,
Get the current base URI.
*/
SERD_API
-SerdNode
+const SerdNode*
serd_read_state_get_base_uri(SerdReadState* state,
SerdURI* out);
diff --git a/src/reader.c b/src/reader.c
index 6d9cc599..d6c97eec 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -1493,12 +1493,12 @@ serd_read_state_expand(SerdReadState* state,
}
SERD_API
-SerdNode
+const SerdNode*
serd_read_state_get_base_uri(SerdReadState* state,
SerdURI* out)
{
*out = state->base_uri;
- return state->base_uri_node;
+ return &state->base_uri_node;
}
SERD_API
diff --git a/src/serd_internal.h b/src/serd_internal.h
index 83416942..dd57af1e 100644
--- a/src/serd_internal.h
+++ b/src/serd_internal.h
@@ -98,26 +98,28 @@ is_digit(const uint8_t c)
return in_range(c, '0', '9');
}
-/** UTF-8 strlen.
- * @return Lengh of @a utf8 in characters.
- * @param utf8 A null-terminated UTF-8 string.
- * @param out_n_bytes (Output) Set to the size of @a utf8 in bytes.
- */
+/**
+ UTF-8 strlen.
+ @return Length of @c str in characters.
+ @param str A null-terminated UTF-8 string.
+ @param n_bytes (Output) Set to the size of @a str in bytes (incl. NULL).
+*/
static inline size_t
-serd_strlen(const uint8_t* utf8, size_t* out_n_bytes)
+serd_strlen(const uint8_t* str, size_t* n_bytes)
{
size_t n_chars = 0;
size_t i = 0;
- for (; utf8[i]; ++i) {
- if ((utf8[i] & 0xC0) != 0x80) {
+ for (; str[i]; ++i) {
+ if ((str[i] & 0xC0) != 0x80) {
// Does not start with `10', start of a new character
++n_chars;
}
}
- if (out_n_bytes) {
- *out_n_bytes = i + 1;
+ if (n_bytes) {
+ *n_bytes = i + 1;
}
return n_chars;
}
+
#endif // SERD_INTERNAL_H