MTREE_INIT(3)

NAME ✨

mtree_init, mtree_free β€” the glow-up and the goodbye for a merkle tree πŸŽ€


LIBRARY 🌸

Librecast library (that's liblibrecast, bestie, you link it with -llibrecast) πŸ’–


SYNOPSIS πŸ¦‹

#include <librecast/mtree.h>

int mtree_init(mtree_t *tree, size_t sz);
void mtree_free(mtree_t *tree);

Compile and link with -llibrecast. Periodt. πŸ‘‘


DESCRIPTION πŸ’…

okay so listen. mtree_init() sets up your merkle tree β€” the struct you pass in as tree β€” and gives it a base data size of sz. And what is sz, you ask? It's literally the size, in bytes, of the base file or data that's gonna get built into the tree later when you call mtree_build(3). So like, this is the pre-game. The setup era. The getting-ready-with-me. 🌈

Then there's mtree_free(), which does the exact opposite vibe β€” it frees that tree. Cleanup queen. No drama, no leftover memory lying around. πŸ’…βœ¨


RETURN VALUE 🌟

mtree_init() comes back with zero when everything slayed. If it doesn't go well? You get -1 returned, and errno gets set to spill the tea about what actually went wrong. 😭

mtree_free() returns no value at all β€” it's a void, she doesn't do receipts β€” and it preserves errno. So whatever errno was before, it's still that after. Iconic, honestly. 🫢


ERRORS πŸ’€

  • ENOMEM β€” Not enough space / cannot allocate memory (POSIX.1-2001). The memory said no. πŸ™ˆ

SEE ALSO πŸ”₯

mdex_get(3), mdex_put(3), mdex_del(3)


and that's the whole page, bestie!! this lil' guide is from the Librecast crew, dated 2023-06-20, and yeah β€” it's MTREE_INIT(3) in the Librecast Programmer's Manual. no cap. mwah πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from