aboutsummaryrefslogtreecommitdiffstats
path: root/src/inserter.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-01-02 14:12:54 -0500
committerDavid Robillard <d@drobilla.net>2022-01-28 21:57:05 -0500
commit155fceabe7070b6610d577734734d038d097b088 (patch)
tree5bbbf327a00c2637f85f006c4b429ecc3b3cb1a3 /src/inserter.c
parent1159aea45d9bc4ade2e82856be403d58e050f32d (diff)
downloadserd-155fceabe7070b6610d577734734d038d097b088.tar.gz
serd-155fceabe7070b6610d577734734d038d097b088.tar.bz2
serd-155fceabe7070b6610d577734734d038d097b088.zip
Add assertions for all non-null pointers in the public API
Clang issues warnings at build time based on the SERD_NONNULL annotations, which is a much better approach in general. However, it does not cover cases where the API is being used with another compiler, or without a compiler that can statically check things at all (such as Python or other dynamic language bindings). In those situations, getting a clear assertion message is a lot less confusing than a random crash somewhere in serd, and it makes it clear that the bug is in the caller, so I think it's worth the tedious verbosity.
Diffstat (limited to 'src/inserter.c')
-rw-r--r--src/inserter.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/inserter.c b/src/inserter.c
index f5fd6ef1..100fc23a 100644
--- a/src/inserter.c
+++ b/src/inserter.c
@@ -19,6 +19,7 @@
#include "serd/serd.h"
+#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -109,6 +110,8 @@ serd_inserter_on_event(SerdInserterData* const data,
SerdSink*
serd_inserter_new(SerdModel* const model, const SerdNode* const default_graph)
{
+ assert(model);
+
SerdInserterData* const data =
(SerdInserterData*)calloc(1, sizeof(SerdInserterData));