tools/perf/util/strbuf.h
Source file repositories/reference/linux-study-clean/tools/perf/util/strbuf.h
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/strbuf.h- Extension
.h- Size
- 3021 bytes
- Lines
- 96
- 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
assert.hstdarg.hstddef.hstring.hlinux/compiler.hsys/types.h
Detected Declarations
struct strbuffunction strbuf_availfunction strbuf_setlenfunction strbuf_addstr
Annotated Snippet
struct strbuf {
size_t alloc;
size_t len;
char *buf;
};
#define STRBUF_INIT { 0, 0, strbuf_slopbuf }
/*----- strbuf life cycle -----*/
int strbuf_init(struct strbuf *buf, ssize_t hint);
void strbuf_release(struct strbuf *buf);
char *strbuf_detach(struct strbuf *buf, size_t *);
/*----- strbuf size related -----*/
static inline ssize_t strbuf_avail(const struct strbuf *sb) {
return sb->alloc ? sb->alloc - sb->len - 1 : 0;
}
int strbuf_grow(struct strbuf *buf, size_t);
static inline int strbuf_setlen(struct strbuf *sb, size_t len) {
if (!sb->alloc) {
int ret = strbuf_grow(sb, 0);
if (ret)
return ret;
}
assert(len < sb->alloc);
sb->len = len;
sb->buf[len] = '\0';
return 0;
}
/*----- add data in your buffer -----*/
int strbuf_addch(struct strbuf *sb, int c);
int strbuf_add(struct strbuf *buf, const void *, size_t);
static inline int strbuf_addstr(struct strbuf *sb, const char *s) {
return strbuf_add(sb, s, strlen(s));
}
int strbuf_addf(struct strbuf *sb, const char *fmt, ...) __printf(2, 3);
/* XXX: if read fails, any partial read is undone */
ssize_t strbuf_read(struct strbuf *, int fd, ssize_t hint);
#endif /* __PERF_STRBUF_H */
Annotation
- Immediate include surface: `assert.h`, `stdarg.h`, `stddef.h`, `string.h`, `linux/compiler.h`, `sys/types.h`.
- Detected declarations: `struct strbuf`, `function strbuf_avail`, `function strbuf_setlen`, `function strbuf_addstr`.
- 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.