diff options
author | David Robillard <d@drobilla.net> | 2024-09-27 18:38:19 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-09-27 18:38:19 -0400 |
commit | a3fd8b05a7b062256dd298d929fb99f8f3757f73 (patch) | |
tree | 4b7b7b249c7c3011e552cca9bc9f5dbfa2818144 | |
parent | 287e07ebaa5fbcf9be0ce0cb1981798fc04bc9f1 (diff) | |
download | serd-a3fd8b05a7b062256dd298d929fb99f8f3757f73.tar.gz serd-a3fd8b05a7b062256dd298d929fb99f8f3757f73.tar.bz2 serd-a3fd8b05a7b062256dd298d929fb99f8f3757f73.zip |
Make more pointer variables const
-rw-r--r-- | src/n3.c | 10 | ||||
-rw-r--r-- | src/reader.c | 4 | ||||
-rw-r--r-- | src/writer.c | 4 | ||||
-rw-r--r-- | test/test_reader_writer.c | 5 |
4 files changed, 12 insertions, 11 deletions
@@ -925,10 +925,10 @@ read_verb(SerdReader* const reader, Ref* const dest) */ *dest = push_node(reader, SERD_CURIE, "", 0); - SerdStatus st = read_PN_PREFIX(reader, *dest); - bool ate_dot = false; - SerdNode* node = deref(reader, *dest); - const int next = peek_byte(reader); + SerdStatus st = read_PN_PREFIX(reader, *dest); + bool ate_dot = false; + const SerdNode* const node = deref(reader, *dest); + const int next = peek_byte(reader); if (!st && node->n_bytes == 1 && node->buf[0] == 'a' && next != ':' && !is_PN_CHARS_BASE((uint32_t)next)) { pop_node(reader, *dest); @@ -1540,7 +1540,7 @@ token_equals(SerdReader* const reader, const char* const tok, const size_t n) { - SerdNode* const node = deref(reader, ref); + const SerdNode* const node = deref(reader, ref); if (!node || node->n_bytes != n) { return false; } diff --git a/src/reader.c b/src/reader.c index aa24a9ca..5cd978bf 100644 --- a/src/reader.c +++ b/src/reader.c @@ -127,8 +127,8 @@ pop_node(SerdReader* const reader, const Ref ref) SERD_STACK_ASSERT_TOP(reader, ref); --reader->n_allocs; #endif - SerdNode* const node = deref(reader, ref); - uint8_t* const top = reader->stack.buf + reader->stack.size; + SerdNode* const node = deref(reader, ref); + const uint8_t* const top = reader->stack.buf + reader->stack.size; serd_stack_pop_aligned(&reader->stack, (size_t)(top - (uint8_t*)node)); } return 0; diff --git a/src/writer.c b/src/writer.c index 0df44797..3905cb9c 100644 --- a/src/writer.c +++ b/src/writer.c @@ -745,8 +745,8 @@ write_uri_node(SerdWriter* const writer, serd_uri_parse(node->buf, &uri); SERD_RESTORE_WARNINGS serd_uri_resolve(&uri, &in_base_uri, &abs_uri); - bool rooted = uri_is_under(&writer->base_uri, &writer->root_uri); - SerdURI* root = rooted ? &writer->root_uri : &writer->base_uri; + const bool rooted = uri_is_under(&writer->base_uri, &writer->root_uri); + const SerdURI* root = rooted ? &writer->root_uri : &writer->base_uri; UriSinkContext ctx = {writer, SERD_SUCCESS}; if (!uri_is_under(&abs_uri, root) || writer->syntax == SERD_NTRIPLES || writer->syntax == SERD_NQUADS) { diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c index 6b84b1e6..515d5e5b 100644 --- a/test/test_reader_writer.c +++ b/test/test_reader_writer.c @@ -164,8 +164,9 @@ test_writer(const char* const path) assert(serd_writer_end_anon(writer, NULL)); assert(serd_writer_get_env(writer) == env); - uint8_t buf[] = {0x80, 0, 0, 0, 0}; - SerdNode s = serd_node_from_string(SERD_URI, USTR("")); + const uint8_t buf[] = {0x80, 0, 0, 0, 0}; + + SerdNode s = serd_node_from_string(SERD_URI, USTR("")); SerdNode p = serd_node_from_string(SERD_URI, USTR("http://example.org/pred")); SerdNode o = serd_node_from_string(SERD_LITERAL, buf); |