diff options
author | David Robillard <d@drobilla.net> | 2021-09-10 20:11:46 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-09-10 20:54:28 -0400 |
commit | 904c1b4d699aeb1ce170f0cd996a01d2d06812e3 (patch) | |
tree | 35a4a9f75a395a958ab0ea5fffeca81ce733bbc1 /include/zix/bitset.h | |
parent | 1f8c8118f2d42f495dbe6e3adb2a95c87a92e8e0 (diff) | |
download | zix-904c1b4d699aeb1ce170f0cd996a01d2d06812e3.tar.gz zix-904c1b4d699aeb1ce170f0cd996a01d2d06812e3.tar.bz2 zix-904c1b4d699aeb1ce170f0cd996a01d2d06812e3.zip |
Add nullability annotations
This allows clang to issue warnings at compile time when null is passed to a
non-null parameter. For public entry points, also add assertions to catch such
issues when the compiler does not support this.
Diffstat (limited to 'include/zix/bitset.h')
-rw-r--r-- | include/zix/bitset.h | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/include/zix/bitset.h b/include/zix/bitset.h index ee8b805..b6e4bac 100644 --- a/include/zix/bitset.h +++ b/include/zix/bitset.h @@ -48,27 +48,35 @@ typedef uint8_t ZixBitsetTally; /// Clear a Bitset ZIX_API void -zix_bitset_clear(ZixBitset* b, ZixBitsetTally* t, size_t n_bits); +zix_bitset_clear(ZixBitset* ZIX_NONNULL b, + ZixBitsetTally* ZIX_NONNULL t, + size_t n_bits); /// Set bit `i` in `t` to 1 ZIX_API void -zix_bitset_set(ZixBitset* b, ZixBitsetTally* t, size_t i); +zix_bitset_set(ZixBitset* ZIX_NONNULL b, + ZixBitsetTally* ZIX_NONNULL t, + size_t i); /// Clear bit `i` in `t` (set to 0) ZIX_API void -zix_bitset_reset(ZixBitset* b, ZixBitsetTally* t, size_t i); +zix_bitset_reset(ZixBitset* ZIX_NONNULL b, + ZixBitsetTally* ZIX_NONNULL t, + size_t i); /// Return the `i`th bit in `t` ZIX_PURE_API bool -zix_bitset_get(const ZixBitset* b, size_t i); +zix_bitset_get(const ZixBitset* ZIX_NONNULL b, size_t i); /// Return the number of set bits in `b` up to bit `i` (non-inclusive) ZIX_PURE_API size_t -zix_bitset_count_up_to(const ZixBitset* b, const ZixBitsetTally* t, size_t i); +zix_bitset_count_up_to(const ZixBitset* ZIX_NONNULL b, + const ZixBitsetTally* ZIX_NONNULL t, + size_t i); /** Return the number of set bits in `b` up to bit `i` (non-inclusive) if bit @@ -76,9 +84,9 @@ zix_bitset_count_up_to(const ZixBitset* b, const ZixBitsetTally* t, size_t i); */ ZIX_PURE_API size_t -zix_bitset_count_up_to_if(const ZixBitset* b, - const ZixBitsetTally* t, - size_t i); +zix_bitset_count_up_to_if(const ZixBitset* ZIX_NONNULL b, + const ZixBitsetTally* ZIX_NONNULL t, + size_t i); /** @} |