STRINGLIST(3)
π STRINGLIST(3) β like, the stringlist girlies β¨
okay so bestie, welcome to stringlist(3), aka the Library Functions Manual page you're gonna want bookmarked. this is the standard C library situation, libc and -lc, and it's giving "i handle lists of strings so you don't have to" energy. let's go π
πΈ NAME πΈ
stringlist, sl_init, sl_add, sl_free, sl_find β the stringlist manipulation functions, fr fr. these are the little guys that let you mess with lists of strings. π
π¦ LIBRARY π¦
Standard C Library β libc, -lc. the classic. the icon. π
β¨ SYNOPSIS β¨
okay, the way that you get these in your life is:
#include <stringlist.h>
StringList *
sl_init();
int
sl_add(StringList *sl, char *item);
void
sl_free(StringList *sl, int freeall);
char *
sl_find(StringList *sl, const char *item);
like, copy that verbatim bestie, it's literally the whole vibe check for your includes and signatures. π
π DESCRIPTION π
so the stringlist functions manipulate stringlists, which are β you guessed it β lists of strings that extend automatically if necessary. she grows! she adapts! main character energy, no cap. π±β¨
the StringList structure has the following definition:
typedef struct _stringlist {
char **sl_str;
size_t sl_max;
size_t sl_cur;
} StringList;
and the fields are, like, so important:
sl_strβ a pointer to the base of the array containing the list. the foundation. the roots. π«Άsl_maxβ the size ofsl_str. how much room she's got. πsl_curβ 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. π (if you get theNULLβ¦ that's a no from her.)sl_free()β releases memory occupied bysland thesl->sl_strarray. and iffreeallis non-zero, then each of the items withinsl->sl_stris released as well. so like, be intentional with thatfreeallflag, bestie, it decides whether the items get cleaned up too. π§Ήπsl_add()β additemtosl->sl_stratsl->sl_cur, extending the size ofsl->sl_str. returns zero upon success,-1upon failure. she ate and left no crumbs when she returns0. π₯sl_find()β finditeminsl, returningNULLif it is not found. so if you get aNULLback, she's just not there, don't take it personally. π
π SEE ALSO π
iykyk, these two are literally the parents of everything here. πΈ
β HISTORY β
the stringlist functions appeared in FreeBSD 2.2.6 and NetBSD 1.3. vintage. iconic. herstory. πβ¨
and that's the whole page, bestie β periodt. π«Άπ
this edition of the page is the Debian one, dated November 28, 1999, so like, yes she's been slaying since before you were born, and honestly? respect. ππ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 1997, 1999 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms