aboutsummaryrefslogtreecommitdiffstats
path: root/src/uri.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-01-13 14:31:00 +0100
committerDavid Robillard <d@drobilla.net>2023-12-02 16:27:02 -0500
commit82f8f804773b10c42b17a30872a59ed76b062794 (patch)
tree73b6ebdde09b41126f37f3f4fc7fbe44b07ec3fb /src/uri.c
parent84bab08585dec858807a6130bd2d71f304b889f0 (diff)
downloadserd-82f8f804773b10c42b17a30872a59ed76b062794.tar.gz
serd-82f8f804773b10c42b17a30872a59ed76b062794.tar.bz2
serd-82f8f804773b10c42b17a30872a59ed76b062794.zip
Add SerdBuffer type for mutable buffers
This avoids const violations from abusing SerdChunk as a mutable buffer for string sinks.
Diffstat (limited to 'src/uri.c')
-rw-r--r--src/uri.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/uri.c b/src/uri.c
index 9f70aa40..c25f2155 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -27,7 +27,6 @@ serd_file_uri_parse(const char* const uri, char** const hostname)
if (!(path = strchr(auth, '/'))) {
return NULL;
}
-
if (hostname) {
const size_t len = (size_t)(path - auth);
*hostname = (char*)calloc(len + 1, 1);
@@ -40,27 +39,26 @@ serd_file_uri_parse(const char* const uri, char** const hostname)
++path;
}
- SerdChunk chunk = {NULL, 0};
+ SerdBuffer buffer = {NULL, 0};
for (const char* s = path; *s; ++s) {
if (*s == '%') {
if (*(s + 1) == '%') {
- serd_chunk_sink("%", 1, &chunk);
+ serd_buffer_sink("%", 1, &buffer);
++s;
} else if (is_hexdig(*(s + 1)) && is_hexdig(*(s + 2))) {
const uint8_t hi = hex_digit_value((const uint8_t)s[1]);
const uint8_t lo = hex_digit_value((const uint8_t)s[2]);
const char c = (char)((hi << 4U) | lo);
- serd_chunk_sink(&c, 1, &chunk);
+ serd_buffer_sink(&c, 1, &buffer);
s += 2;
} else {
s += 2; // Junk escape, ignore
}
} else {
- serd_chunk_sink(s, 1, &chunk);
+ serd_buffer_sink(s, 1, &buffer);
}
}
-
- return serd_chunk_sink_finish(&chunk);
+ return serd_buffer_sink_finish(&buffer);
}
bool