STRINGLIST(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… 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 of sl_str. how much room she's got. πŸ“
  • sl_cur β€” the offset in sl_str of the current element. where we're at rn. πŸ“

the following stringlist manipulation functions are available:

  • sl_init() β€” create a stringlist. returns a pointer to a StringList, or NULL in case of failure. 😭 (if you get the NULL… that's a no from her.)
  • sl_free() β€” releases memory occupied by sl and the sl->sl_str array. and if freeall is non-zero, then each of the items within sl->sl_str is released as well. so like, be intentional with that freeall flag, bestie, it decides whether the items get cleaned up too. πŸ§ΉπŸ’€
  • sl_add() β€” add item to sl->sl_str at sl->sl_cur, extending the size of sl->sl_str. returns zero upon success, -1 upon failure. she ate and left no crumbs when she returns 0. πŸ”₯
  • sl_find() β€” find item in sl, returning NULL if it is not found. so if you get a NULL back, she's just not there, don't take it personally. πŸ™ˆ

πŸŽ€ SEE ALSO πŸŽ€

  • free(3) β€” the memory-liberation icon πŸ’œ
  • malloc(3) β€” the memory-acquisition icon πŸ’œ

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