stringlist(3bsd)
π stringlist(3bsd) β LOCAL π
okay bestie, welcome to stringlist(3bsd) from the <rainbow>LOCAL</rainbow> manual, section 3bsd β yes it's giving very "I read man pages for fun" but honestly? same. π
β¨ NAME β¨
stringlist, sl_init, sl_add, sl_free, sl_find, sl_delete β the stringlist manipulation functions, aka the little squad that handles your lists of strings for you. π
π LIBRARY π
Utility functions from BSD systems β that's libbsd, link it with -lbsd. π«Ά
πΈ SYNOPSIS πΈ
#include <stringlist.h>
(psst β go check libbsd(7) for how the include actually works, no cap. π)
StringList *
sl_init(void);
int
sl_add(StringList *sl, char *item);
void
sl_free(StringList *sl, int freeall);
char *
sl_find(StringList *sl, const char *item);
int
sl_delete(StringList *sl, const char *item, int freeit);
π¦ DESCRIPTION π¦
So the stringlist functions do exactly what it says on the tin: they manipulate stringlists, which are literally lists of strings that extend automatically if necessary. it's giving self-care, honestly. she grows when she needs to. π
The StringList structure has this exact definition:
typedef struct _stringlist {
char **sl_str;
size_t sl_max;
size_t sl_cur;
} StringList;
where:
sl_strβ is a pointer to the base of the array containing the list. (the home base, the main character. π )sl_maxβ is the size ofsl_str. (how much room she's got. π)sl_curβ is the offset insl_strof the current element. (where we're at rn. π)
The following stringlist manipulation functions are available:
sl_init()β Create a stringlist. Returns a pointer to aStringList, orNULLin case of failure. β¨ (manifesting a non-NULLreturn for you bestie, but be ready for thatNULLfr fr.)sl_free()β Releases memory occupied bysland thesl->sl_strarray. Iffreeallis non-zero, then each of the items withinsl->sl_stris released as well. π§Ή (that second part is the deep clean β only iffreeallis non-zero, don't come for me.)sl_add()β Additemtosl->sl_stratsl->sl_cur, extending the size ofsl->sl_str. Returns zero upon success,-1upon failure. πsl_find()β Finditeminsl, returningNULLif it's not found. π (ghosted, but politely.)sl_delete()β Removeitemfrom the list. Iffreeitis non-zero, the string is freed. Returns0if the name is found and-1if the name is not found. πβ‘οΈποΈ
π SEE ALSO π
free(3), malloc(3) β go read those too, they're the OGs. π
π HISTORY π
The stringlist functions appeared in FreeBSD 2.2.6 and NetBSD 1.3. vintage but still slaying. π
cute little sign-off: this page came from Debian and it's dated May 6, 2010 β yeah she's a Taurus-era icon and we love her for it. ππ¦β¨ bye bestie, go sl_free your leaks π
π¦ where this page comes from
- alpine 3.22: libbsd-doc 0.12.2-r0 Β· BSD-3-Clause
- alpine 3.23: libbsd-doc 0.12.2-r0 Β· BSD-3-Clause
- alpine 3.24: libbsd-doc 0.12.2-r0 Β· BSD-3-Clause
- arch rolling: libbsd 0.12.2-2 Β· custom
- debian bookworm: libbsd-dev 0.11.7-2
- debian trixie: libbsd-dev 0.12.2-2
- epel 10: libbsd-devel 0.12.2-4.el10_0 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- epel 9: libbsd-devel 0.12.2-1.el9 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 43: libbsd-devel 0.12.2-6.fc43 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 43: libbsd-devel 0.12.2-6.fc43 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 44: libbsd-devel 0.12.2-7.fc44 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 44: libbsd-devel 0.12.2-7.fc44 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- nixos 26.05: libbsd 0.12.2
- opensuse-leap 16.0: libbsd-devel 0.11.7-160000.3.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libbsd-devel 0.11.7-160000.3.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libbsd-devel 0.11.7-160000.3.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libbsd-devel 0.11.7-160000.3.2 Β· BSD-3-Clause
- ubuntu noble: libbsd-dev 0.12.1-1build1
- ubuntu noble: libbsd-dev 0.12.1-1build1.1
- ubuntu questing: libbsd-dev 0.12.2-2build1
- ubuntu resolute: libbsd-dev 0.12.2-2build2
- ubuntu stonking: libbsd-dev 0.12.2-3
- Copyright (c) 1997, 1999 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms