aboutsummaryrefslogtreecommitdiffstats
path: root/src/node.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-03-15 23:21:34 -0400
committerDavid Robillard <d@drobilla.net>2018-11-25 09:21:03 +0100
commitf046eb982627f344fc0eeff6be82028318862e67 (patch)
treea8216165d6e74ff5650e4cdd5a2a44b05b611f63 /src/node.c
parentfc6ef04d8b94909523708c1bdbb9ea8f42063662 (diff)
downloadserd-f046eb982627f344fc0eeff6be82028318862e67.tar.gz
serd-f046eb982627f344fc0eeff6be82028318862e67.tar.bz2
serd-f046eb982627f344fc0eeff6be82028318862e67.zip
Use SerdBuffer 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.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/node.c b/src/node.c
index 92bf3bde..20f67fda 100644
--- a/src/node.c
+++ b/src/node.c
@@ -176,27 +176,28 @@ serd_node_new_file_uri(const uint8_t* path,
evil ? "/" : "");
}
- SerdChunk chunk = { uri, uri_len };
+ SerdBuffer buffer = { uri, uri_len };
for (size_t i = 0; i < path_len; ++i) {
if (evil && 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", 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