LC_CTX_NEW(3)

πŸ“¦
version 0.11.2 Β· 2 versions
  • 0.11.2 Β· debian trixie, nixos 26.05, nixpkgs unstable, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.5.1 Β· debian bookworm
, in debian trixie, nixos 26.05, nixpkgs unstable, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

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

okay bestie, sit down, hydrate, and let's talk about the absolute foundation of everything Librecast: making a context and then, when you're done, letting it go. it's giving main character energy but make it memory management. πŸ¦‹


✨ NAME ✨

lc_ctx_new, lc_ctx_free β€” create and free Librecast contexts πŸŽ€

πŸ“š LIBRARY πŸ“š

Librecast library (liblibrecast, -llibrecast) β€” yeah you gotta link it, no cap.

🌸 SYNOPSIS 🌸

#include <librecast/net.h>

lc_ctx_t *lc_ctx_new(void);
void lc_ctx_free(lc_ctx_t *ctx);

Compile and link with -llibrecast.


πŸ’… DESCRIPTION πŸ’…

so lc_ctx_new() is the moment. it creates a brand new Librecast context and sets up the environment for you. think of it as the getting-ready montage before the actual plot. once you're done with it, call lc_ctx_free(3) β€” that's not a suggestion, that's the law. 🫢

and lc_ctx_free()? it invalidates and frees a Librecast context that you made with lc_ctx_new(3). it's the graceful exit. the closing credits. ✨

🎯 RETURN VALUE 🎯

lc_ctx_new() hands you back a pointer to a lc_ctx_t handle. that's your baby now. πŸ‘‘

but if things go sideways, it returns NULL and sets errno to ENOMEM. yes, that ENOMEM. 😭

the lc_ctx_free() function returns no value. literally nothing. it just does the thing and dips. πŸ’€

πŸ’€ ERRORS πŸ’€

lc_ctx_new() can fail with this one:

  • ENOMEM β€” Out of memory. Possibly, the application hit the RLIMIT_AS or RLIMIT_DATA limit described in getrlimit(2). not me getting rate-limited by the kernel itself πŸ™ˆ

🌈 EXAMPLE 🌈

Program source

lc_ctx_t *lctx;
lctx = lc_ctx_new();

/* your Librecast program here */

lc_ctx_free(lctx); /* free context when done */

see? create, do your lil thing, free. the whole cycle. iconic. 🌟

πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie!! this lil gem came to you from the LIBRECAST crew, dated 2020-08-01, page LC_CTX_NEW(3) β€” stay hydrated, free your contexts, and slay πŸ’–βœ¨

πŸ“¦ where this page comes from