github ashvardanian/StringZilla v4.4.1
v4.4.1: Harden C 99 API with `static n` Array Arguments

latest releases: v4.6.0, v4.5.1, v4.5.0...
3 months ago

Added sz_at_least(n) macro for C99's static array parameter syntax, enabling compile-time bounds checking on fixed-size array arguments. In C mode, Clang will now warn when passing undersized arrays to annotated functions. The macro expands to nothing in C++ for compatibility.

// Compiler can now warn if the digest buffer is smaller than 32 bytes
void sz_sha256_state_digest(..., sz_u8_t digest[sz_at_least(32)]);

// Lookup tables must be at least 256 bytes
void sz_lookup(..., char const lut[sz_at_least(256)]);

See LWN.net article for background on this feature and its use in the Linux kernel.

Patch

  • Improve: Harden C API with static n arrays (#289) (039c4b4)

Don't miss a new StringZilla release

NewReleases is sending notifications on new releases.