MDEX_PUT(3)

πŸ’– MDEX_PUT(3) πŸ’–

okay bestie, gather round, it's mdex_put from the Librecast Programmer's Manual and she is so much simpler than she looks 🫢


✨ NAME ✨

mdex_put β€” insert an entry into a multicast index 🌈


πŸ“š LIBRARY πŸ“š

Librecast library (liblibrecast, -llibrecast) πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <librecast/mdex.h>

int mdex_put(mdex_t *mdex, unsigned char *hash, size_t hashlen, mdex_entry_t *entry);

Compile and link with -llibrecast. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically? mdex_put takes the value of entry and stores it in the multicast index mdex, using hash (of length hashlen) as the key. like, the hash is the lil name tag and the entry is the whole personality, and they get introduced to each other. πŸ’–

and here's the iconic part: entry may be NULL, and an entry will still be created. no entry? no problem. the key still gets to exist. main character energy fr fr. πŸ‘‘


⭐ RETURN VALUE ⭐

mdex_put() returns zero on success β€” slay. πŸŽ‰

On error, -1 is returned, and errno is set to indicate the error. (yes she's telling on herself, that's the whole point.) 😭


πŸ’€ ERRORS πŸ’€

  • EINVAL β€” Invalid argument. bestie listen. both mdex and hash are required (not NULL), and hashlen must be > 0. no empty vibes allowed, no vibe check passed with a null, none of it. πŸ™ˆ
  • ENOMEM β€” Not enough space/cannot allocate memory (POSIX.1-2001). the memory said "not today" and honestly? valid. πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

mdex_init(3), mdex_free(3), mdex_get(3), mdex_del(3), lc_share(3) β€” the whole friend group, go say hi. 🫢🌸


mwah πŸ’‹ this page came straight from the Librecast crew, dated 2023-06-20, and yeah β€” it's page MDEX_PUT(3) of the Librecast Programmer's Manual. that's the whole thing bestie, go put some entries in a multicast index and text me when it works. πŸ’œβœ¨

πŸ“¦ where this page comes from