aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-12 13:31:24 +0100
committerDavid Robillard <d@drobilla.net>2020-11-12 13:31:24 +0100
commita815f33ec3de9a145a5846e46e6dd2f052dbfd7d (patch)
tree1a9cc47685f86705945c2dfd63c5475099a6e349
parent1319a748cbb40c4d7257e3dd2537bcfee2a9b164 (diff)
downloadserd-a815f33ec3de9a145a5846e46e6dd2f052dbfd7d.tar.gz
serd-a815f33ec3de9a145a5846e46e6dd2f052dbfd7d.tar.bz2
serd-a815f33ec3de9a145a5846e46e6dd2f052dbfd7d.zip
Relax nullability annotation on allocation functions
In practice almost nobody checks for failed allocation, including unfortunately the serd tests and serdi itself. Adding a struct mode to conditionally define this would be a good idea to support allocation-hardened code, but for now just mark them as unspecified instead. On the bright side, this documents the nature of the returned pointers nicely.
-rw-r--r--include/serd/serd.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index a1a15138..6e9b19dd 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -48,9 +48,11 @@
#ifdef __clang__
# define SERD_NONNULL _Nonnull
# define SERD_NULLABLE _Nullable
+# define SERD_ALLOCATED _Null_unspecified
#else
# define SERD_NONNULL
# define SERD_NULLABLE
+# define SERD_ALLOCATED
#endif
#define SERD_PURE_API SERD_API SERD_PURE_FUNC
@@ -707,7 +709,7 @@ typedef SerdStatus (*SerdEndSink)(void* SERD_NULLABLE handle,
Create a new environment.
*/
SERD_API
-SerdEnv* SERD_NULLABLE
+SerdEnv* SERD_ALLOCATED
serd_env_new(const SerdNode* SERD_NULLABLE base_uri);
/**
@@ -803,7 +805,7 @@ serd_env_foreach(const SerdEnv* SERD_NONNULL env,
Create a new RDF reader.
*/
SERD_API
-SerdReader* SERD_NULLABLE
+SerdReader* SERD_ALLOCATED
serd_reader_new(SerdSyntax syntax,
void* SERD_NULLABLE handle,
void (*SERD_NULLABLE free_handle)(void* SERD_NULLABLE),
@@ -971,7 +973,7 @@ serd_reader_free(SerdReader* SERD_NULLABLE reader);
Create a new RDF writer.
*/
SERD_API
-SerdWriter* SERD_NULLABLE
+SerdWriter* SERD_ALLOCATED
serd_writer_new(SerdSyntax syntax,
SerdStyle style,
SerdEnv* SERD_NONNULL env,