ProcMapsLoad
Description
Read and parse /proc/self/maps. The full file is held inside out->raw for the lifetime of the ProcMaps so each entry’s path can borrow from it without a separate copy.
Parameters
| Name | Direction | Description |
|---|---|---|
out |
out | Populated on success. |
alloc |
in | Allocator for the raw buffer and entries vector. |
Success
Returns true; out->entries is populated.
Failure
Returns false; logs the failing step. out is left zeroed.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
ProcMaps.c:13:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:41:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; out->allocator = alloc;
out->cache = VecInitT(out->cache, alloc);
if (!ProcMapsLoad(&out->maps, alloc)) {
VecDeinit(&out->cache);
MemSet(out, 0, sizeof(*out));- In
ProcMaps.c:157:
// ---------------------------------------------------------------------------
bool ProcMapsLoad(ProcMaps *out, Allocator *alloc) {
if (!out || !alloc) {
LOG_ERROR("ProcMapsLoad: NULL argument");- In
ProcMaps.c:159:
bool ProcMapsLoad(ProcMaps *out, Allocator *alloc) {
if (!out || !alloc) {
LOG_ERROR("ProcMapsLoad: NULL argument");
return false;
}- In
ProcMaps.c:173:
FILE *f = fopen("/proc/self/maps", "rb");
if (!f) {
LOG_SYS_ERROR("ProcMapsLoad: fopen(/proc/self/maps) failed");
ProcMapsDeinit(out);
return false;- In
ProcMaps.c:184:
u64 grown_to = out->raw.length + CHUNK + 1;
if (!StrReserve(&out->raw, grown_to)) {
LOG_ERROR("ProcMapsLoad: failed to grow buffer");
fclose(f);
ProcMapsDeinit(out);- In
ProcMaps.c:196:
fclose(f);
if (out->raw.length == 0) {
LOG_ERROR("ProcMapsLoad: /proc/self/maps was empty");
ProcMapsDeinit(out);
return false;
Last updated on