stralloc_copys(3)
β¨ stralloc_copys(3) β¨
okay bestie, welcome to the Library Functions Manual π this one's called stralloc_copys and it's here to copy data into a stralloc. tiny function, huge slay, let's get into it π
πΈ NAME πΈ
stralloc_copys β copy data into a stralloc π«Ά
π¦ SYNTAX π¦
#include <libowfat/stralloc.h>
int stralloc_copys(stralloc* sa,const char* buf);
π DESCRIPTION π
so here's the vibe. stralloc_copys copies a \0-terminated string from buf into sa, and it does not copy the \0 itself. just the good stuff before it. β¨
it's literally the same as:
stralloc_copyb(&sa, buf, str_len(buf))
periodt. same energy, same result, no cap. π―
whatever sa was holding before? gone. overwritten. truncated. it's giving fresh start, main character energy, the old data did not survive the vibe check π
now for the important part, and listen closely because this one matters: if stralloc_copys runs out of memory, it leaves sa alone and returns 0. if everything goes fine, it returns 1. that's it. that's the whole deal. π
π RETURN VALUE π
1β success, we ate, no crumbs π0β memory allocation failure π
π₯ SEE ALSO π₯
ngl the whole "leaves sa alone on failure" thing is lowkey iconic? like it doesn't wreck your existing data just because the malloc flopped. respectful. we love a considerate function. π
okay that's the whole page bestie, mwah π this was stralloc_copys(3) straight out of the Library Functions Manual, and yes iykyk, come back whenever you need to remember which one of these returns a 1 π§β
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- debian bookworm: libowfat-dev 0.32-4 Β· GPL-2.0-only
- debian trixie: libowfat-dev 0.32-5 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- ubuntu noble: libowfat-dev 0.32-4.1build1 Β· GPL-2.0-only
- ubuntu questing: libowfat-dev 0.32-5
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms