aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/env.c7
-rw-r--r--src/node.c14
-rw-r--r--src/reader.c10
-rw-r--r--src/serd_internal.h2
-rw-r--r--src/uri.c6
-rw-r--r--src/writer.c6
6 files changed, 22 insertions, 23 deletions
diff --git a/src/env.c b/src/env.c
index 605be6e6..c37b6b6b 100644
--- a/src/env.c
+++ b/src/env.c
@@ -245,10 +245,9 @@ serd_env_expand_node(const SerdEnv* env,
return SERD_NODE_NULL;
}
const size_t len = prefix.len + suffix.len; // FIXME: UTF-8?
- SerdNode ret = { NULL, len, len, 0, SERD_URI };
- ret.buf = (uint8_t*)malloc(ret.n_bytes + 1);
- snprintf((char*)ret.buf, ret.n_bytes + 1,
- "%s%s", prefix.buf, suffix.buf);
+ uint8_t* buf = (uint8_t*)malloc(len + 1);
+ SerdNode ret = { buf, len, len, 0, SERD_URI };
+ snprintf((char*)buf, ret.n_bytes + 1, "%s%s", prefix.buf, suffix.buf);
return ret;
}
case SERD_URI: {
diff --git a/src/node.c b/src/node.c
index 575b2ff0..7f6e9863 100644
--- a/src/node.c
+++ b/src/node.c
@@ -165,9 +165,9 @@ serd_node_new_file_uri(const uint8_t* path,
} else if (!escape || is_uri_path_char(path[i])) {
serd_chunk_sink(path + i, 1, &chunk);
} else {
- char escape[4] = { '%', 0, 0, 0 };
- snprintf(escape + 1, sizeof(escape) - 1, "%X", path[i]);
- serd_chunk_sink(escape, 3, &chunk);
+ 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_chunk_sink_finish(&chunk);
@@ -310,19 +310,19 @@ SerdNode
serd_node_new_blob(const void* buf, size_t size, bool wrap_lines)
{
const size_t len = ((size + 2) / 3) * 4 + (wrap_lines ? (size / 57) : 0);
- SerdNode node = { (uint8_t*)calloc(1, len + 2),
- len, len, 0, SERD_LITERAL };
+ uint8_t* str = (uint8_t*)calloc(1, len + 2);
+ SerdNode node = { str, len, len, 0, SERD_LITERAL };
for (size_t i = 0, j = 0; i < size; i += 3, j += 4) {
uint8_t in[4] = { 0, 0, 0, 0 };
size_t n_in = MIN(3, size - i);
memcpy(in, (const uint8_t*)buf + i, n_in);
if (wrap_lines && i > 0 && (i % 57) == 0) {
- ((uint8_t*)node.buf)[j++] = '\n';
+ str[j++] = '\n';
node.flags |= SERD_HAS_NEWLINE;
}
- encode_chunk((uint8_t*)node.buf + j, in, n_in);
+ encode_chunk(str + j, in, n_in);
}
return node;
}
diff --git a/src/reader.c b/src/reader.c
index ac9d3778..d17b80a5 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -408,16 +408,16 @@ bad_char(SerdReader* reader, Ref dest, const char* fmt, uint8_t c)
push_replacement(reader, dest);
// Skip bytes until the next start byte
- for (uint8_t c = peek_byte(reader); (c & 0x80);) {
- eat_byte_safe(reader, c);
- c = peek_byte(reader);
+ for (uint8_t b = peek_byte(reader); (b & 0x80);) {
+ eat_byte_safe(reader, b);
+ b = peek_byte(reader);
}
return SERD_SUCCESS;
}
static SerdStatus
-read_utf8_character(SerdReader* reader, Ref dest, const uint8_t c)
+read_utf8_character(SerdReader* reader, Ref dest, uint8_t c)
{
unsigned size = 1;
if ((c & 0xE0) == 0xC0) { // Starts with `110'
@@ -917,7 +917,7 @@ except:
}
inline static bool
-is_token_end(const uint8_t c)
+is_token_end(uint8_t c)
{
switch (c) {
case 0x9: case 0xA: case 0xD: case 0x20: case '\0':
diff --git a/src/serd_internal.h b/src/serd_internal.h
index 9a875daa..67e47e95 100644
--- a/src/serd_internal.h
+++ b/src/serd_internal.h
@@ -181,7 +181,7 @@ serd_bulk_sink_write(const void* buf, size_t len, SerdBulkSink* bsink)
// Write as much as possible into the remaining buffer space
memcpy(bsink->buf + bsink->size, buf, n);
bsink->size += n;
- buf = (uint8_t*)buf + n;
+ buf = (const uint8_t*)buf + n;
len -= n;
// Flush page if buffer is full
diff --git a/src/uri.c b/src/uri.c
index f7d17e59..1812bb93 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -446,15 +446,15 @@ write_rel_path(SerdSink sink,
// Find the number of up references ("..") required
size_t up = 0;
- for (size_t i = last_shared_sep + 1; i < base_len; ++i) {
- if (uri_path_at(base, i) == '/') {
+ for (size_t s = last_shared_sep + 1; s < base_len; ++s) {
+ if (uri_path_at(base, s) == '/') {
++up;
}
}
// Write up references
size_t len = 0;
- for (size_t i = 0; i < up; ++i) {
+ for (size_t u = 0; u < up; ++u) {
len += sink("../", 3, stream);
}
diff --git a/src/writer.c b/src/writer.c
index 5c85073a..84a5d43b 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -641,7 +641,7 @@ serd_writer_new(SerdSyntax syntax,
SerdStyle style,
SerdEnv* env,
const SerdURI* base_uri,
- SerdSink sink,
+ SerdSink ssink,
void* stream)
{
const WriteContext context = WRITE_CONTEXT_NULL;
@@ -653,7 +653,7 @@ serd_writer_new(SerdSyntax syntax,
writer->root_uri = SERD_URI_NULL;
writer->base_uri = base_uri ? *base_uri : SERD_URI_NULL;
writer->anon_stack = serd_stack_new(sizeof(WriteContext));
- writer->sink = sink;
+ writer->sink = ssink;
writer->stream = stream;
writer->error_sink = NULL;
writer->error_handle = NULL;
@@ -666,7 +666,7 @@ serd_writer_new(SerdSyntax syntax,
writer->last_sep = SEP_NONE;
writer->empty = true;
if (style & SERD_STYLE_BULK) {
- writer->bulk_sink = serd_bulk_sink_new(sink, stream, SERD_PAGE_SIZE);
+ writer->bulk_sink = serd_bulk_sink_new(ssink, stream, SERD_PAGE_SIZE);
}
return writer;
}