tools/lib/subcmd/subcmd-util.h
Source file repositories/reference/linux-study-clean/tools/lib/subcmd/subcmd-util.h
File Facts
- System
- Linux kernel
- Corpus path
tools/lib/subcmd/subcmd-util.h- Extension
.h- Size
- 1678 bytes
- Lines
- 76
- 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.
Dependency Surface
stdarg.hstdlib.hstdio.hlinux/compiler.h
Detected Declarations
function reportfunction diefunction astrcat
Annotated Snippet
if ((nr) > alloc) { \
if (alloc_nr(alloc) < (nr)) \
alloc = (nr); \
else \
alloc = alloc_nr(alloc); \
x = xrealloc((x), alloc * sizeof(*(x))); \
} \
} while(0)
static inline void *xrealloc(void *ptr, size_t size)
{
void *ret = realloc(ptr, size);
if (!ret)
die("Out of memory, realloc failed");
return ret;
}
#define astrcatf(out, fmt, ...) \
({ \
char *tmp = *(out); \
if (asprintf((out), "%s" fmt, tmp ?: "", ## __VA_ARGS__) == -1) \
die("asprintf failed"); \
free(tmp); \
})
static inline void astrcat(char **out, const char *add)
{
char *tmp = *out;
if (asprintf(out, "%s%s", tmp ?: "", add) == -1)
die("asprintf failed");
free(tmp);
}
#endif /* __SUBCMD_UTIL_H */
Annotation
- Immediate include surface: `stdarg.h`, `stdlib.h`, `stdio.h`, `linux/compiler.h`.
- Detected declarations: `function report`, `function die`, `function astrcat`.
- 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.