stralloc_ready(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay bestie, say hi to stralloc_ready β€” she's the girl who makes sure your stralloc has room to breathe. That's literally it: provide space in a stralloc. Serving cunt and serving bytes. ✨


🌸 SYNTAX 🌸

so you pull her in like this:

#include <libowfat/stralloc.h>

int stralloc_ready(stralloc* sa,size_t len);

no cap, that's the whole entrance. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea. stralloc_ready makes sure that sa has enough space allocated to hold len bytes. It's giving personal assistant energy fr fr. Let me break it down:

  • if sa is not allocated, stralloc_ready allocates at least len bytes of space, and returns 1. boom, done, slay. πŸ’…
  • if sa is already allocated but not enough to hold len bytes, stralloc_ready allocates at least len bytes of space, copies the old string into the new space, frees the old space, and returns 1. iconic behaviour honestly β€” she moves your whole wardrobe into a bigger closet and tosses the old one. πŸ‘‘
⚠️ heads up bestie: note that this changes sa.s. like, the pointer itself moves. don't be holding onto a stale sa.s and then acting surprised, iykyk. πŸ™ˆ

and if stralloc_ready runs out of memory? she leaves sa alone and returns 0. no drama, no half-moved furniture, she just walks out. πŸ’€


πŸ“ RETURN VALUE πŸ“

  • 1 β€” success, we ate πŸ”₯
  • 0 β€” memory allocation failure, tragic but she told you straight 😭

🌈 SEE ALSO 🌈


and that's the whole page babes!! this one lives in the Library Functions Manual, filed under stralloc_ready(3) β€” no version, no date, just vibes and one very reliable girl. mwah, love u, go write some C πŸ«ΆπŸ’–βœ¨