stralloc_copyb(3)
π NAME π
okay so bestie, meet stralloc_copyb β the function that copies data into a stralloc β¨
β¨ SYNTAX β¨
first things first, you gotta pull in the header:
#include <libowfat/stralloc.h>
and here's the whole vibe of the function signature, character for character:
int stralloc_copyb(stralloc* sa,const char* buf,size_t len);
π¦ DESCRIPTION π¦
so here's what stralloc_copyb does, and it's honestly so thoughtful of it π«Ά
It first makes sure that sa has enough space allocated to hold len bytes. Like, it does the whole "do we have room??" check for you before anything else. Then β and only then β it copies the first len bytes from buf into the stralloc. Slay. π
Important vibe check: whatever sa was holding before? Gone. Overwritten. Truncated. It does not preserve the old data, it does not append, it does not pass go. It's giving clean slate energy, and if you were attached to what was in there, that's a you problem, bestie π
And now the memory drama: if stralloc_copys runs out of memory, stralloc_copys leaves sa alone and return 0 β otherwise it returns 1. (yes, that's exactly how the page says it, we simply report the lore as it was written π)
ngl the whole point is: it never half-does the job and leaves you with a broken stralloc. Either it works, or sa is untouched. Iconic behaviour, truly. π
π RETURN VALUE π
1β success, we ate, no crumbs π₯0β memory allocation failure, and it's not you, it's the malloc π
and that's the whole page, bestie π this was stralloc_copyb(3) from the Library Functions Manual β go forth, copy bytes, be the main character of your own memory management β¨ππ¦
π¦ 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