stralloc_copy(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 πŸ’–

stralloc_copy β€” copy data into a stralloc 🫢

okay so real quick, before we even get into it: this is page stralloc_copy(3) from the Library Functions Manual, part of libowfat. she's a section 3 library function, she's iconic, and she's about to make your stralloc hold a whole new string. let's GO πŸ’…


πŸ“œ SYNTAX πŸ“œ

#include <libowfat/stralloc.h>

int stralloc_copy(stralloc* sato,stralloc* safrom);

🌸 DESCRIPTION 🌸

So. stralloc_copy copies the string stored in safrom into sa. no cap. it's literally the same thing as calling:

stralloc_copyb(&sato, safrom.s, safrom.len)

so if you already know stralloc_copyb you already know her, she's just the glow-up version that takes a whole stralloc as the source instead of a raw pointer plus a length. ✨

⚠️ heads up bestie: safrom must already be allocated. don't come at her with an unallocated source, she will not be doing that for you. πŸ™ˆ

the data that sa previously contained? overwritten and truncated. gone. deceased. not coming back. πŸ’€ so if you cared about whatever was in there before, you should've copied it somewhere else first, that's on you.

and if stralloc_copy has trouble allocating memory β€” like, the allocator said no β€” she returns 0. otherwise she returns 1. that's it, that's the whole deal.


πŸ”₯ RETURN VALUE πŸ”₯

  • 1 β€” success, we ate, the copy is copied πŸ‘‘
  • 0 β€” memory allocation failure, the vibe check failed, no memory for you 😭

πŸ‘€ SEE ALSO πŸ‘€


and that's the page!! πŸŽ€ tysm for reading, this was stralloc_copy(3) from the Library Functions Manual (libowfat's own), and yes she's giving library-functions-manual realness. mwah, bye bestie πŸ’œπŸ¦‹