diff options
author | David Robillard <d@drobilla.net> | 2024-03-28 10:20:46 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-03-28 10:20:46 -0400 |
commit | 6aed064084c8c1af02adb46b0066aaee1f436edf (patch) | |
tree | d618dc61fe9d2ed60f592e83b33753029eb91441 /src/reader.c | |
parent | a3051f0fbe9b76bb91498d62647dad1d27b43691 (diff) | |
download | serd-6aed064084c8c1af02adb46b0066aaee1f436edf.tar.gz serd-6aed064084c8c1af02adb46b0066aaee1f436edf.tar.bz2 serd-6aed064084c8c1af02adb46b0066aaee1f436edf.zip |
Add assertions for all non-null pointers in the public API
Diffstat (limited to 'src/reader.c')
-rw-r--r-- | src/reader.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/reader.c b/src/reader.c index 5d87216d..1936808a 100644 --- a/src/reader.c +++ b/src/reader.c @@ -9,6 +9,7 @@ #include "serd_internal.h" +#include <assert.h> #include <errno.h> #include <stdarg.h> #include <stdint.h> @@ -237,6 +238,7 @@ serd_reader_free(SerdReader* const reader) void* serd_reader_get_handle(const SerdReader* const reader) { + assert(reader); return reader->handle; } @@ -244,6 +246,8 @@ void serd_reader_add_blank_prefix(SerdReader* const reader, const uint8_t* const prefix) { + assert(reader); + free(reader->bprefix); reader->bprefix_len = 0; reader->bprefix = NULL; @@ -260,6 +264,7 @@ void serd_reader_set_default_graph(SerdReader* const reader, const SerdNode* const graph) { + assert(reader); serd_node_free(&reader->default_graph); reader->default_graph = serd_node_copy(graph); } @@ -267,6 +272,9 @@ serd_reader_set_default_graph(SerdReader* const reader, SerdStatus serd_reader_read_file(SerdReader* const reader, const uint8_t* const uri) { + assert(reader); + assert(uri); + uint8_t* const path = serd_file_uri_parse(uri, NULL); if (!path) { return SERD_ERR_BAD_ARG; @@ -307,6 +315,9 @@ serd_reader_start_stream(SerdReader* const reader, const uint8_t* const name, const bool bulk) { + assert(reader); + assert(file); + return serd_reader_start_source_stream(reader, bulk ? (SerdSource)fread : serd_file_read_byte, @@ -324,6 +335,10 @@ serd_reader_start_source_stream(SerdReader* const reader, const uint8_t* const name, const size_t page_size) { + assert(reader); + assert(read_func); + assert(error_func); + return serd_byte_source_open_source( &reader->source, read_func, error_func, stream, name, page_size); } @@ -345,6 +360,8 @@ serd_reader_prepare(SerdReader* const reader) SerdStatus serd_reader_read_chunk(SerdReader* const reader) { + assert(reader); + SerdStatus st = SERD_SUCCESS; if (!reader->source.prepared) { st = serd_reader_prepare(reader); @@ -365,6 +382,8 @@ serd_reader_read_chunk(SerdReader* const reader) SerdStatus serd_reader_end_stream(SerdReader* const reader) { + assert(reader); + return serd_byte_source_close(&reader->source); } @@ -389,6 +408,10 @@ serd_reader_read_source(SerdReader* const reader, const uint8_t* const name, const size_t page_size) { + assert(reader); + assert(source); + assert(error); + SerdStatus st = serd_reader_start_source_stream( reader, source, error, stream, name, page_size); @@ -408,6 +431,9 @@ serd_reader_read_source(SerdReader* const reader, SerdStatus serd_reader_read_string(SerdReader* const reader, const uint8_t* const utf8) { + assert(reader); + assert(utf8); + serd_byte_source_open_string(&reader->source, utf8); SerdStatus st = serd_reader_prepare(reader); |