tools/perf/util/strlist.c
Source file repositories/reference/linux-study-clean/tools/perf/util/strlist.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/strlist.c- Extension
.c- Size
- 4091 bytes
- Lines
- 204
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
strlist.herrno.hstdio.hstdlib.hstring.hunistd.hlinux/zalloc.h
Detected Declarations
function str_node__deletefunction strlist__node_deletefunction strlist__node_cmpfunction strlist__addfunction strlist__loadfunction strlist__removefunction strlist__parse_list_entryfunction strlist__parse_listfunction strlist__delete
Annotated Snippet
if (access(subst, F_OK) == 0) {
err = strlist__load(slist, subst);
goto out;
}
if (slist->file_only) {
err = -ENOENT;
goto out;
}
}
err = strlist__add(slist, s);
out:
free(subst);
return err;
}
static int strlist__parse_list(struct strlist *slist, const char *list, const char *subst_dir)
{
char *sep, *s = strdup(list), *sdup = s;
int err;
if (s == NULL)
return -ENOMEM;
while ((sep = strchr(s, ',')) != NULL) {
*sep = '\0';
err = strlist__parse_list_entry(slist, s, subst_dir);
if (err != 0)
return err;
s = sep + 1;
}
err = *s ? strlist__parse_list_entry(slist, s, subst_dir) : 0;
free(sdup);
return err;
}
struct strlist *strlist__new(const char *list, const struct strlist_config *config)
{
struct strlist *slist = malloc(sizeof(*slist));
if (slist != NULL) {
bool file_only = false;
const char *dirname = NULL;
if (config) {
dirname = config->dirname;
file_only = config->file_only;
}
rblist__init(&slist->rblist);
slist->rblist.node_cmp = strlist__node_cmp;
slist->rblist.node_new = strlist__node_new;
slist->rblist.node_delete = strlist__node_delete;
slist->file_only = file_only;
if (list && strlist__parse_list(slist, list, dirname) != 0)
goto out_error;
}
return slist;
out_error:
free(slist);
return NULL;
}
void strlist__delete(struct strlist *slist)
{
if (slist != NULL)
rblist__delete(&slist->rblist);
}
struct str_node *strlist__entry(const struct strlist *slist, unsigned int idx)
{
struct str_node *snode = NULL;
struct rb_node *rb_node;
rb_node = rblist__entry(&slist->rblist, idx);
if (rb_node)
snode = container_of(rb_node, struct str_node, rb_node);
return snode;
}
Annotation
- Immediate include surface: `strlist.h`, `errno.h`, `stdio.h`, `stdlib.h`, `string.h`, `unistd.h`, `linux/zalloc.h`.
- Detected declarations: `function str_node__delete`, `function strlist__node_delete`, `function strlist__node_cmp`, `function strlist__add`, `function strlist__load`, `function strlist__remove`, `function strlist__parse_list_entry`, `function strlist__parse_list`, `function strlist__delete`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.