diff options
author | David Robillard <d@drobilla.net> | 2021-01-13 14:31:00 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 16:27:02 -0500 |
commit | 82f8f804773b10c42b17a30872a59ed76b062794 (patch) | |
tree | 73b6ebdde09b41126f37f3f4fc7fbe44b07ec3fb /src/node.c | |
parent | 84bab08585dec858807a6130bd2d71f304b889f0 (diff) | |
download | serd-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/node.c')
-rw-r--r-- | src/node.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -200,29 +200,29 @@ serd_node_new_file_uri(const char* const path, } } - SerdChunk chunk = {uri, uri_len}; + SerdBuffer buffer = {uri, uri_len}; for (size_t i = 0; i < path_len; ++i) { if (path[i] == '%') { - serd_chunk_sink("%%", 2, &chunk); + serd_buffer_sink("%%", 2, &buffer); } else if (is_uri_path_char(path[i])) { - serd_chunk_sink(path + i, 1, &chunk); + serd_buffer_sink(path + i, 1, &buffer); #ifdef _WIN32 } else if (path[i] == '\\') { - serd_chunk_sink("/", 1, &chunk); + serd_buffer_sink("/", 1, &buffer); #endif } else { char escape_str[10] = {'%', 0, 0, 0, 0, 0, 0, 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); } } - const char* const string = serd_chunk_sink_finish(&chunk); + const char* const string = serd_buffer_sink_finish(&buffer); if (string && out) { serd_uri_parse(string, out); } - return serd_node_from_substring(SERD_URI, string, chunk.len); + return serd_node_from_substring(SERD_URI, string, buffer.len); } SerdNode |