From 30185a4d55786c2d649332fdcbd23e736f74dc80 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 2 Nov 2022 15:50:51 -0400 Subject: Relax nullability constraints for BTree values These pointers are truly opaque, the library does not care about their value at all, and a zero can be stored successfully. --- include/zix/attributes.h | 8 +++++--- include/zix/btree.h | 16 ++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/zix/attributes.h b/include/zix/attributes.h index b076fa7..dc367a1 100644 --- a/include/zix/attributes.h +++ b/include/zix/attributes.h @@ -83,10 +83,12 @@ # define ZIX_NONNULL _Nonnull # define ZIX_NULLABLE _Nullable # define ZIX_ALLOCATED _Null_unspecified +# define ZIX_UNSPECIFIED _Null_unspecified #else -# define ZIX_NONNULL ///< A non-null pointer -# define ZIX_NULLABLE ///< A nullable pointer -# define ZIX_ALLOCATED ///< An allocated (possibly null) pointer +# define ZIX_NONNULL ///< A non-null pointer +# define ZIX_NULLABLE ///< A nullable pointer +# define ZIX_ALLOCATED ///< An allocated (possibly null) pointer +# define ZIX_UNSPECIFIED ///< A pointer with unspecified nullability #endif /** diff --git a/include/zix/btree.h b/include/zix/btree.h index 7199dbc..05b520e 100644 --- a/include/zix/btree.h +++ b/include/zix/btree.h @@ -116,7 +116,7 @@ zix_btree_size(const ZixBTree* ZIX_NONNULL t); /// Insert the element `e` into `t` ZIX_API ZixStatus -zix_btree_insert(ZixBTree* ZIX_NONNULL t, void* ZIX_NULLABLE e); +zix_btree_insert(ZixBTree* ZIX_NONNULL t, void* ZIX_UNSPECIFIED e); /** Remove the value `e` from `t`. @@ -132,10 +132,10 @@ zix_btree_insert(ZixBTree* ZIX_NONNULL t, void* ZIX_NULLABLE e); */ ZIX_API ZixStatus -zix_btree_remove(ZixBTree* ZIX_NONNULL t, - const void* ZIX_NULLABLE e, - void* ZIX_NULLABLE* ZIX_NONNULL out, - ZixBTreeIter* ZIX_NONNULL next); +zix_btree_remove(ZixBTree* ZIX_NONNULL t, + const void* ZIX_UNSPECIFIED e, + void* ZIX_UNSPECIFIED* ZIX_NONNULL out, + ZixBTreeIter* ZIX_NONNULL next); /** Set `ti` to an element exactly equal to `e` in `t`. @@ -145,7 +145,7 @@ zix_btree_remove(ZixBTree* ZIX_NONNULL t, ZIX_API ZixStatus zix_btree_find(const ZixBTree* ZIX_NONNULL t, - const void* ZIX_NULLABLE e, + const void* ZIX_UNSPECIFIED e, ZixBTreeIter* ZIX_NONNULL ti); /** @@ -167,12 +167,12 @@ ZixStatus zix_btree_lower_bound(const ZixBTree* ZIX_NONNULL t, ZixCompareFunc ZIX_NULLABLE compare_key, const void* ZIX_NULLABLE compare_key_user_data, - const void* ZIX_NULLABLE key, + const void* ZIX_UNSPECIFIED key, ZixBTreeIter* ZIX_NONNULL ti); /// Return the data at the given position in the tree ZIX_PURE_API -void* ZIX_NULLABLE +void* ZIX_UNSPECIFIED zix_btree_get(ZixBTreeIter ti); /// Return an iterator to the first (smallest) element in `t` -- cgit v1.2.1