MachoOpenFromMemory
Description
Parse a Mach-O image from an in-memory byte range – L-value / ownership-transfer form (mirrors VecInsertL).
Takes the caller’s Buf by pointer. The parser snapshots the Buf and zeroes the caller’s *in so any post-call use is an empty Buf rather than a stale alias. Allocator comes from the Buf. The zero-on-take invariant holds on success and failure.
Usage example (from documentation)
Buf buf = BufInit(&alloc);
FileRead(&f, &buf);
MachoOpenFromMemory(&m, &buf);
// buf is now zeroed.
Success
Returns true; out owns the bytes; *in is zeroed.
Failure
Returns false; the bytes have been freed; *in is zeroed; out is left zeroed.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
MachO.c:419:
// MemSets the caller's view to zero. Anything that fails past the
// snapshot cleans up via MachoDeinit -- the buffer never leaks.
bool MachoOpenFromMemory(Macho *out, Buf *in) {
if (!out || !in || !BufData(in) || !BufAllocator(in)) {
LOG_FATAL("MachoOpenFromMemory: NULL argument (contract violation)");- In
MachO.c:421:
bool MachoOpenFromMemory(Macho *out, Buf *in) {
if (!out || !in || !BufData(in) || !BufAllocator(in)) {
LOG_FATAL("MachoOpenFromMemory: NULL argument (contract violation)");
}
Buf taken = *in;- In
MachO.c:458:
MemCopy(BufData(©), data, data_size);
BufResize(©, (size)data_size);
return MachoOpenFromMemory(out, ©);
}- In
MachO.c:471:
return false;
}
return MachoOpenFromMemory(out, &data);
}
Last updated on