Browse Source

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.
zrythm_meson
David Robillard 2 years ago
parent
commit
a815f33ec3
  1. 8
      include/serd/serd.h

8
include/serd/serd.h

@ -48,9 +48,11 @@ @@ -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, @@ -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, @@ -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); @@ -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,

Loading…
Cancel
Save