diff options
author | David Robillard <d@drobilla.net> | 2018-06-15 09:26:17 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 16:27:02 -0500 |
commit | b631e7a3d6a807aaf4919396b62ba96e1a9f0bd9 (patch) | |
tree | 70a49bcc4d79d83d0f80f115da457514e09977d0 /src/node.c | |
parent | fe0b6d5d4d78cb31e1bf2381198890d070e46ed1 (diff) | |
download | serd-b631e7a3d6a807aaf4919396b62ba96e1a9f0bd9.tar.gz serd-b631e7a3d6a807aaf4919396b62ba96e1a9f0bd9.tar.bz2 serd-b631e7a3d6a807aaf4919396b62ba96e1a9f0bd9.zip |
Bring read/write interface closer to the C standard
Diffstat (limited to 'src/node.c')
-rw-r--r-- | src/node.c | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -56,7 +56,7 @@ static const SerdNodeFlags meta_mask = (SERD_HAS_DATATYPE | SERD_HAS_LANGUAGE); static SerdNode* serd_new_from_uri(SerdURIView uri, SerdURIView base); -SERD_PURE_FUNC static size_t +static size_t serd_uri_string_length(const SerdURIView* const uri) { size_t len = uri->path_prefix.length; @@ -76,12 +76,15 @@ serd_uri_string_length(const SerdURIView* const uri) } static size_t -string_sink(const void* const buf, const size_t len, void* const stream) +string_sink(const void* const buf, + const size_t size, + const size_t nmemb, + void* const stream) { char** ptr = (char**)stream; - memcpy(*ptr, buf, len); - *ptr += len; - return len; + memcpy(*ptr, buf, size * nmemb); + *ptr += size * nmemb; + return nmemb; } SERD_PURE_FUNC static size_t @@ -428,18 +431,18 @@ serd_new_file_uri(const SerdStringView path, const SerdStringView hostname) SerdBuffer buffer = {uri, uri_len}; for (size_t i = 0; i < path.length; ++i) { if (path.data[i] == '%') { - serd_buffer_sink("%%", 2, &buffer); + serd_buffer_sink("%%", 1, 2, &buffer); } else if (is_uri_path_char(path.data[i])) { - serd_buffer_sink(path.data + i, 1, &buffer); + serd_buffer_sink(path.data + i, 1, 1, &buffer); #ifdef _WIN32 } else if (path.data[i] == '\\') { - serd_buffer_sink("/", 1, &buffer); + serd_buffer_sink("/", 1, 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.data[i]); - serd_buffer_sink(escape_str, 3, &buffer); + serd_buffer_sink(escape_str, 1, 3, &buffer); } } |