MDEX_INIT(3)

πŸ’– mdex_init(3) β€” Librecast Programmer's Manual πŸ’–

okay bestie, welcome to the mdex_init page, straight outta the Librecast Programmer's Manual ✨ this is where we spin up (and tear down) a multicast index, and honestly? it's giving low-level elegance. let's get into it 🫢


🌸 NAME 🌸

mdex_init, mtree_free β€” initialize and free a multicast index

(no fr, that's what the NAME line says, mtree_free and all β€” we keep the lore exact πŸ’…)


πŸ“š LIBRARY πŸ“š

Librecast library (liblibrecast, -llibrecast)


✨ SYNOPSIS ✨

#include <librecast/mdex.h>

mdex_t *mdex_init(size_t entries);
void mdex_free(mdex_t *mdex);

Compile and link with -llibrecast.


πŸ¦‹ DESCRIPTION πŸ¦‹

So, the mdex_init function initializes a multicast index. That's it, that's the whole vibe β€” it sets the thing up so you can use it πŸ‘‘

The entries argument gives the initial number of entries to allocate. And listen, bestie, this is just a hint for initial memory allocation β€” the index will be resized as required. So don't stress about getting the number perfect, it's not that deep, the index grows on its own 🌱


πŸ’« RETURN VALUE πŸ’«

mdex_init() returns a pointer to a mdex_t handle. That pointer is your new bestie and it should be freed by passing it to mdex_free() when you're done with it β€” no leaving it hanging, that's rude πŸ™ˆ

On error, NULL is returned, and errno is set to indicate the error.

The mdex_free() function returns no value, and preserves errno. Iconic behaviour, honestly β€” it cleans up after itself and doesn't mess with your errno. periodt πŸ’…


😭 ERRORS 😭

  • ENOMEM β€” Not enough space/cannot allocate memory (POSIX.1-2001).
bestie if you see this one, your memory said "not today" πŸ’€ there is genuinely no room, it's not a you problem, it's a system problem.

πŸ‘€ SEE ALSO πŸ‘€

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

like, go read those next, they're the rest of the squad fr fr 🌈


mwah πŸ’‹ that's the whole page. this one shipped from LIBRECAST, dated 2023-06-20, and it lives under the title MDEX_INIT(3) β€” go forth and initialize your multicast indexes, main character πŸŽ€βœ¨

πŸ“¦ where this page comes from