aboutsummaryrefslogtreecommitdiffstats
path: root/src/node.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-01-13 14:31:00 +0100
committerDavid Robillard <d@drobilla.net>2021-03-07 15:32:23 -0500
commita7be33a7640ee51066c41eded5812d9cee5ad27e (patch)
tree8c2cbe96a6973c73320ff793d452e36fe511b745 /src/node.c
parent96bcba9cd94879794de477ae7c5c04971fbd6f32 (diff)
downloadserd-a7be33a7640ee51066c41eded5812d9cee5ad27e.tar.gz
serd-a7be33a7640ee51066c41eded5812d9cee5ad27e.tar.bz2
serd-a7be33a7640ee51066c41eded5812d9cee5ad27e.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/node.c')
-rw-r--r--src/node.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/node.c b/src/node.c
index 02aedbf2..415b4031 100644
--- a/src/node.c
+++ b/src/node.c
@@ -208,28 +208,28 @@ serd_node_new_file_uri(const uint8_t* path,
}
}
- SerdChunk chunk = {uri, uri_len};
+ SerdBuffer buffer = {uri, uri_len};
for (size_t i = 0; i < path_len; ++i) {
if (is_windows && path[i] == '\\') {
- serd_chunk_sink("/", 1, &chunk);
+ serd_buffer_sink("/", 1, &buffer);
} else if (path[i] == '%') {
- serd_chunk_sink("%%", 2, &chunk);
+ serd_buffer_sink("%%", 2, &buffer);
} else if (!escape || is_uri_path_char(path[i])) {
- serd_chunk_sink(path + i, 1, &chunk);
+ serd_buffer_sink(path + i, 1, &buffer);
} else {
char escape_str[4] = {'%', 0, 0, 0};
snprintf(escape_str + 1, sizeof(escape_str) - 1, "%X", (unsigned)path[i]);
- serd_chunk_sink(escape_str, 3, &chunk);
+ serd_buffer_sink(escape_str, 3, &buffer);
}
}
-
- serd_chunk_sink_finish(&chunk);
+ serd_buffer_sink_finish(&buffer);
if (out) {
- serd_uri_parse(chunk.buf, out);
+ serd_uri_parse((const uint8_t*)buffer.buf, out);
}
- return serd_node_from_substring(SERD_URI, chunk.buf, chunk.len);
+ return serd_node_from_substring(
+ SERD_URI, (const uint8_t*)buffer.buf, buffer.len);
}
SerdNode