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*argzand*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*argzand*argz_len. (thus,*argz_lenwill 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*argzand*argz_len. bye bestie ๐argz_extract()โ the opposite ofargz_create(). it takes the argz vector(argz, argz_len)and fills the array starting at argv with pointers to the substrings, and a finalNULL, making a UNIX-style argv vector. the array argv must have room forargz_count(argz, argz_len) + 1pointers. do not forget that+ 1, i am begging ๐argz_insert()โ the opposite ofargz_delete(). it inserts the argument entry at position before into the argz vector(*argz, *argz_len)and updates*argzand*argz_len. if before isNULL, 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 isNULL, the first entry is returned. otherwise, the entry following is returned. it returnsNULLif 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_countwill be incremented by the number of replacements. tracking its own body count ๐ฅargz_stringify()โ the opposite ofargz_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 ๐
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
- Copyright 2002, Walter Harms <walter.harms@informatik.uni-oldenburg.de>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms