stringlist(3)

stringlist3

Stringlist manipulation functions

Usage

#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);

Library

Standard C Library (libc, -lc)

Overview

The stringlist functions manipulate stringlists, which are lists of strings that extend automatically if necessary.

The StringList structure has the following definition:

typedef struct _stringlist {
	char	**sl_str;
	size_t	  sl_max;
	size_t	  sl_cur;
} StringList;
sl_str

a pointer to the base of the array containing the list.

sl_max

the size of sl_str.

sl_cur

the offset in sl_str of the current element.

The following stringlist manipulation functions are available:

sl_init()

Create a stringlist. Returns a pointer to a StringList, or NULL in case of failure.

sl_free()

Releases memory occupied by sl and the sl->sl_str array. If freeall is non-zero, then each of the items within sl->sl_str is released as well.

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.

sl_find()

Find item in sl, returning NULL if it is not found.

Releases

81 releases since FreeBSD 2.2.6-RELEASE; the text changed 42 times.

  1. 2.2.6–3.4
  2. 3.5–3.5.1
  3. 4.0
  4. 4.1–4.2
  5. 4.3
  6. 4.4
  7. 4.5–4.8
  8. 4.9–4.11
  9. 5.0
  10. 5.1–5.5
  11. 6.0–6.3
  12. 6.4
  13. 7.0
  14. 7.1
  15. 7.2
  16. 7.3
  17. 7.4
  18. 8.0
  19. 8.1
  20. 8.2
  21. 8.3
  22. 8.4
  23. 9.0
  24. 9.1
  25. 9.2
  26. 9.3
  27. 10.0
  28. 10.1
  29. 10.2
  30. 10.3
  31. 10.4
  32. 11.0
  33. 11.1
  34. 11.2
  35. 11.3
  36. 11.4
  37. 12.0
  38. 12.1
  39. 12.2
  40. 12.3
  41. 12.4
  42. 13.0–13.2
  43. 13.3–16.0

History

The stringlist functions appeared in FreeBSD 2.2.6 and NetBSD 1.3.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.