argz_add(3)

๐Ÿ’– argz_add(3) โ€” Library Functions Manual ๐Ÿ’–

okay bestie, sit down, hydrate, because today we're learning about argz vectors and honestly? they're giving "sleeper hit of the glibc catalogue." this page covers argz_add, argz_add_sep, argz_append, argz_count, argz_create, argz_create_sep, argz_delete, argz_extract, argz_insert, argz_next, argz_replace, and argz_stringify โ€” the whole friend group ๐Ÿ’…


โœจ NAME โœจ

argz_add, argz_add_sep, argz_append, argz_count, argz_create, argz_create_sep, argz_delete, argz_extract, argz_insert, argz_next, argz_replace, argz_stringify โ€” functions to handle an argz list ๐Ÿฆ‹

๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C library (libc, -lc)

๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <argz.h>

error_t argz_add(char **restrict argz, size_t *restrict argz_len,
                const char *restrict str);

error_t argz_add_sep(char **restrict argz, size_t *restrict argz_len,
                const char *restrict str, int delim);

error_t argz_append(char **restrict argz, size_t *restrict argz_len,
                const char *restrict buf, size_t buf_len);

size_t argz_count(const char *argz, size_t argz_len);

error_t argz_create(char *const argv[], char **restrict argz,
                size_t *restrict argz_len);

error_t argz_create_sep(const char *restrict str, int sep,
                char **restrict argz, size_t *restrict argz_len);

void argz_delete(char **restrict argz, size_t *restrict argz_len,
                char *restrict entry);

void argz_extract(const char *restrict argz, size_t argz_len,
                char **restrict argv);

error_t argz_insert(char **restrict argz, size_t *restrict argz_len,
                char *restrict before, const char *restrict entry);

char *argz_next(const char *restrict argz, size_t argz_len,
                const char *restrict entry);

error_t argz_replace(char **restrict argz, size_t *restrict argz_len,
                const char *restrict str, const char *restrict with,
                unsigned int *restrict replace_count);

void argz_stringify(char *argz, size_t len, int sep);

๐ŸŒธ DESCRIPTION ๐ŸŒธ

first things first: these functions are glibc-specific. that's the vibe. no cap, if you're on a different libc, this is not your moment ๐Ÿ˜ญ

so. an argz vector is a pointer to a character buffer plus a length. the intended interpretation of that character buffer? it's an array of strings, and the strings are separated by null bytes ('\0'). and here's the rule you cannot skip: if the length is nonzero, the last byte of the buffer must be a null byte. periodt.

these functions are for handling argz vectors. the pair (NULL,0) is an argz vector, and conversely, argz vectors of length 0 must have a null pointer. allocation of nonempty argz vectors is done using malloc(3), so that free(3) can be used to dispose of them again. recycle era โ™ป๏ธโœจ

  • argz_add() โ€” adds the string str at the end of the array *argz, and updates *argz and *argz_len. it just. puts it at the end. slay.
  • argz_add_sep() โ€” similar, but it splits the string str into substrings separated by the delimiter delim. for example, one might use this on a UNIX search path with delimiter ':'. it's giving "path parsing but make it cute" ๐Ÿ“
  • argz_append() โ€” appends the argz vector (buf, buf_len) after (*argz, *argz_len) and updates *argz and *argz_len. (thus, *argz_len will be increased by buf_len.) math is math ๐Ÿ’…
  • argz_count() โ€” counts the number of strings, that is, the number of null bytes ('\0'), in (argz, argz_len). it's literally just counting ๐Ÿงฎ
  • argz_create() โ€” converts a UNIX-style argument vector argv, terminated by (char *) 0, into an argz vector (*argz, *argz_len). glow up transformation โœจ
  • argz_create_sep() โ€” converts the null-terminated string str into an argz vector (*argz, *argz_len) by breaking it up at every occurrence of the separator sep. chop chop ๐Ÿช„
  • argz_delete() โ€” removes the substring pointed to by entry from the argz vector (*argz, *argz_len) and updates *argz and *argz_len. bye bestie ๐Ÿ‘‹
  • argz_extract() โ€” the opposite of argz_create(). it takes the argz vector (argz, argz_len) and fills the array starting at argv with pointers to the substrings, and a final NULL, making a UNIX-style argv vector. the array argv must have room for argz_count(argz, argz_len) + 1 pointers. do not forget that + 1, i am begging ๐Ÿ™ˆ
  • argz_insert() โ€” the opposite of argz_delete(). it inserts the argument entry at position before into the argz vector (*argz, *argz_len) and updates *argz and *argz_len. if before is NULL, then entry will inserted at the end. (yes, insert, the main character move ๐Ÿ’–)
  • argz_next() โ€” a function to step through the argz vector. if entry is NULL, the first entry is returned. otherwise, the entry following is returned. it returns NULL if there is no following entry. it's a little cursor walk, no biggie ๐Ÿšถโ™€๏ธ
  • argz_replace() โ€” replaces each occurrence of str with with, reallocating argz as necessary. if replace_count is non-NULL, *replace_count will be incremented by the number of replacements. tracking its own body count ๐Ÿ”ฅ
  • argz_stringify() โ€” the opposite of argz_create_sep(). it transforms the argz vector into a normal string by replacing all null bytes ('\0') except the last by sep. note that "except the last," okay? that last one stays ๐ŸŒˆ

๐Ÿ’ซ RETURN VALUE ๐Ÿ’ซ

all argz functions that do memory allocation have a return type of error_t (an integer type), and return 0 for success, and ENOMEM if an allocation error occurs. so like, zero means we ate, ENOMEM means the memory said no ๐Ÿ˜ญ

๐Ÿ‘‘ ATTRIBUTES ๐Ÿ‘‘

for an explanation of the terms used in this section, see attributes(7).

interface: argz_add(), argz_add_sep(), argz_append(), argz_count(), argz_create(), argz_create_sep(), argz_delete(), argz_extract(), argz_insert(), argz_next(), argz_replace(), argz_stringify()

  • Attribute: Thread safety
  • Value: MT-Safe

yes bestie, the whole entire list is MT-Safe. every single one. group chat is safe to enter ๐Ÿซถ

โญ STANDARDS โญ

GNU.

๐Ÿ’€ BUGS ๐Ÿ’€

argz vectors without a terminating null byte may lead to Segmentation Faults. not a cute look. give it the null byte. it deserves the null byte. do it for me ๐Ÿ™

๐ŸŒŸ SEE ALSO ๐ŸŒŸ

envz_add(3)


and that's the whole page, bestie ๐ŸŽ€ this was argz_add(3) from the Linux man-pages, version 6.20, dated 2026-02-08. go forth and null-terminate responsibly ๐Ÿ’œ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: GPL-1.0-or-later
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms