ZT_NOT_NULL(3)

πŸ’– ZT_NOT_NULL(3) πŸ’–

okay bestie so this is a page from libzt, living in the LOCAL section of your manual β€” yes it's a section 3 (library functions, the fun ones) πŸ’…


✨ NAME ✨

ZT_NOT_NULL, zt_not_null β€” construct a claim that a pointer is not NULL. that's the whole job. it's giving "bestie are you actually there or are you NULL" πŸ’€


πŸŽ€ SYNOPSIS πŸŽ€

#include <zt.h>

#define ZT_NOT_NULL(value) \
  zt_not_null( \
    ZT_CURRENT_LOCATION(), \
    zt_pack_pointer((value), #value))

zt_claim
zt_not_null(zt_location location, zt_value value);

🌸 DESCRIPTION 🌸

so zt_not_null() constructs a claim that a given pointer is not NULL. no cap. but here's the thing β€” you're supposed to use it through the macro ZT_NOT_NULL(), because the macro is the one doing the cute little legwork of passing the source code location and packing the argument for you. the function is the backstage crew, the macro is the main character ✨

and why do you even care? because ZT_NOT_NULL() is lowkey iconic when you couple it with zt_assert() β€” that combo lets you make sure an object was actually correctly produced, allocated or returned, and then the rest of your test can go inspect its properties using zt_check(). like, first confirm the thing exists, then vibe check its personality. periodt 🫢


🧚 IMPLEMENTATION NOTES 🧚

ZT_NOT_NULL() evaluates value only once. so don't stress about it double-dipping on your side effects, bestie, it's not that kind of macro πŸ’–


πŸ‘‘ RETURN VALUES πŸ‘‘

both the macro and the function return a zt_claim structure with the appropriate attributes set. and what do you do with that claim? you usually hand it straight over to zt_check() or to zt_assert(). it's basically a lil gift-wrapped assertion 🎁


πŸ¦‹ SEE ALSO πŸ¦‹

(yes, ZT_NOT_NULL(3) is in there twice. iconic of it, honestly. i'm not touching it, i don't make the rules πŸ’…)


🌈 HISTORY 🌈

the ZT_NOT_NULL() macro and the zt_not_null() function first appeared in libzt 0.1. babies. little origin-story legends πŸ₯Ή


πŸ’œ AUTHORS πŸ’œ

Zygmunt Krynicki <me@zygoon.pl> β€” the genius who brought you this whole thing 🫢


okay that's the whole page, bestie!! this one shipped with libzt 0.3.1, dated January 12, 2020, and fr fr that's it β€” go assert something and slay πŸ’…βœ¨πŸ¦‹