stralloc_readyplus(3)
π stralloc_readyplus β bestie edition π
okay so real talk, this one lives in the Library Functions Manual (that's the manual name, she's fancy like that) and her whole job is: making room in a stralloc. no cap. let's get into it. π
β¨ NAME β¨
stralloc_readyplus β provide space in a stralloc
like... she provides space. that's the whole personality. π
πΈ SYNTAX πΈ
#include <libowfat/stralloc.h>
int stralloc_readyplus(stralloc* sa,size_t len);
copy that exactly bestie, don't get creative with it π
π¦ DESCRIPTION π¦
okay so stralloc_readyplus makes sure that sa has enough space allocated to hold an additional len bytes. key word: additional. she's adding to what's already there, she's not replacing anything, she's not here to ruin your vibe. π
here's the breakdown, and honestly it's giving choose-your-own-adventure:
- If
sais not allocated,stralloc_readyallocates at leastlenbytes of space, and returns1. β¨ - If
sais already allocated, but not enough to holdlenadditional bytes,stralloc_readyallocates at leastsa->len+lenbytes of space, copies the old string into the new space, frees the old space, and returns1. she literally moves your whole life into a bigger apartment and then demolishes the old one. iconic behaviour. π
β οΈ note that this changes sa.s. so if you were holding onto that pointer like it was your emotional support pointer... it's not the same pointer anymore. the way that this matters is genuinely so important. π
and if stralloc_readyplus runs out of memory? she leaves sa alone β untouched, unbothered, not one single change β and returns 0. she would never mess with your data on her way out the door. π«Ά
π RETURN VALUE π
1β success, we ate π0β memory allocation failure, we did not eat π
π SEE ALSO π
okay that's the whole page bestie!! this was stralloc_readyplus(3) from the Library Functions Manual β go forth and allocate responsibly, mwah πβ¨π¦ππ
π¦ 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