BufAllocator
Description
Allocator backing b’s storage. Read-only; rebinding the allocator after init is not supported.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Pe.c:507:
// cleans up via PeDeinit -- the buffer never leaks.
bool PeOpenFromMemory(Pe *out, Buf *in) {
if (!out || !in || !BufData(in) || !BufAllocator(in)) {
LOG_FATAL("PeOpenFromMemory: NULL argument (contract violation)");
}- In
Pe.c:517:
// Initialize the sections vec up-front so PeDeinit on a
// failed-parse path doesn't trip ValidateVec.
out->sections = VecInitT(out->sections, BufAllocator(&taken));
PeContext ctx = {- In
Pdb.c:267:
}
self->stream_sizes = AllocatorAlloc(BufAllocator(&self->data), (size)sizes_bytes, 0);
self->stream_blocks = AllocatorAlloc(BufAllocator(&self->data), (size)ptrs_bytes, 0);
self->stream_block_counts = AllocatorAlloc(BufAllocator(&self->data), (size)counts_bytes, 0);- In
Pdb.c:268:
self->stream_sizes = AllocatorAlloc(BufAllocator(&self->data), (size)sizes_bytes, 0);
self->stream_blocks = AllocatorAlloc(BufAllocator(&self->data), (size)ptrs_bytes, 0);
self->stream_block_counts = AllocatorAlloc(BufAllocator(&self->data), (size)counts_bytes, 0);
if (!self->stream_sizes || !self->stream_blocks || !self->stream_block_counts)- In
Pdb.c:269:
self->stream_sizes = AllocatorAlloc(BufAllocator(&self->data), (size)sizes_bytes, 0);
self->stream_blocks = AllocatorAlloc(BufAllocator(&self->data), (size)ptrs_bytes, 0);
self->stream_block_counts = AllocatorAlloc(BufAllocator(&self->data), (size)counts_bytes, 0);
if (!self->stream_sizes || !self->stream_blocks || !self->stream_block_counts)
return false;- In
Pdb.c:473:
if (out_bytes > (u64)((size)-1))
return NULL;
SectionRva *out = AllocatorAlloc(BufAllocator(&self->data), (size)out_bytes, 0);
if (!out)
return NULL;- In
Pdb.c:477:
return NULL;
u8 *buf = AllocatorAlloc(BufAllocator(&self->data), sz, 0);
if (!buf) {
AllocatorFree(BufAllocator(&self->data), out);- In
Pdb.c:479:
u8 *buf = AllocatorAlloc(BufAllocator(&self->data), sz, 0);
if (!buf) {
AllocatorFree(BufAllocator(&self->data), out);
return NULL;
}- In
Pdb.c:484:
bool read_ok = stream_read(self, section_hdr_stream, 0, buf, sz);
if (!read_ok) {
AllocatorFree(BufAllocator(&self->data), buf);
AllocatorFree(BufAllocator(&self->data), out);
return NULL;- In
Pdb.c:485:
if (!read_ok) {
AllocatorFree(BufAllocator(&self->data), buf);
AllocatorFree(BufAllocator(&self->data), out);
return NULL;
}- In
Pdb.c:494:
(void)BufReadU32LE(&rec, &out[i].virtual_address);
}
AllocatorFree(BufAllocator(&self->data), buf);
*out_count = n;
return out;- In
Pdb.c:549:
// Stream into a flat buffer; the record stream is typically large
// but not unbounded.
u8 *buf = AllocatorAlloc(BufAllocator(&self->data), sz, 0);
if (!buf)
return false;- In
Pdb.c:553:
return false;
if (!stream_read(self, symrec_stream, 0, buf, sz)) {
AllocatorFree(BufAllocator(&self->data), buf);
return false;
}- In
Pdb.c:610:
pp.rva = rva;
if (!pool_append_cstr(pool, name, &pp.name_offset_in_pool)) {
AllocatorFree(BufAllocator(&self->data), buf);
return false;
}- In
Pdb.c:614:
}
if (!VecPushBackR(pending, pp)) {
AllocatorFree(BufAllocator(&self->data), buf);
return false;
}- In
Pdb.c:623:
}
AllocatorFree(BufAllocator(&self->data), buf);
return true;
}- In
Pdb.c:637:
if (!sections || num_sections == 0) {
if (sections)
AllocatorFree(BufAllocator(&self->data), sections);
return true; // can't compute RVAs without section table
}- In
Pdb.c:644:
// the pool may grow during the walk -- StrBegin() can move under
// us each time pool_append_cstr() grows the backing storage.
PendingPubs pending = VecInitT(pending, BufAllocator(&self->data));
bool ok = walk_publics(self, dbi.symrec_stream, sections, num_sections, &self->name_pool, &pending);
AllocatorFree(BufAllocator(&self->data), sections);- In
Pdb.c:646:
PendingPubs pending = VecInitT(pending, BufAllocator(&self->data));
bool ok = walk_publics(self, dbi.symrec_stream, sections, num_sections, &self->name_pool, &pending);
AllocatorFree(BufAllocator(&self->data), sections);
if (!ok) {- In
Pdb.c:698:
// or failure); allocator and bytes are carried by `taken`.
bool PdbOpenFromMemory(Pdb *out, Buf *in) {
if (!out || !in || !BufData(in) || !BufAllocator(in)) {
LOG_FATAL("PdbOpenFromMemory: NULL argument (contract violation)");
}- In
Pdb.c:706:
MemSet(out, 0, sizeof(*out));
out->data = taken;
out->functions = VecInitT(out->functions, BufAllocator(&taken));
out->name_pool = StrInit(BufAllocator(&taken));- In
Pdb.c:707:
out->data = taken;
out->functions = VecInitT(out->functions, BufAllocator(&taken));
out->name_pool = StrInit(BufAllocator(&taken));
u32 num_dir_bytes = 0;- In
Pdb.c:760:
if (!self)
return;
Allocator *alloc = BufAllocator(&self->data);
if (alloc) {
if (self->stream_dir)- In
MachO.c:420:
// 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:428:
MemSet(out, 0, sizeof(*out));
out->data = taken;
out->segments = VecInitT(out->segments, BufAllocator(&taken));
out->sections = VecInitT(out->sections, BufAllocator(&taken));
out->symbols = VecInitT(out->symbols, BufAllocator(&taken));- In
MachO.c:429:
out->data = taken;
out->segments = VecInitT(out->segments, BufAllocator(&taken));
out->sections = VecInitT(out->sections, BufAllocator(&taken));
out->symbols = VecInitT(out->symbols, BufAllocator(&taken));- In
MachO.c:430:
out->segments = VecInitT(out->segments, BufAllocator(&taken));
out->sections = VecInitT(out->sections, BufAllocator(&taken));
out->symbols = VecInitT(out->symbols, BufAllocator(&taken));
MachoContext ctx = {.out = out};- In
Elf.c:479:
// so the buffer never leaks.
bool ElfOpenFromMemory(Elf *out, Buf *in) {
if (!out || !in || !BufData(in) || !BufAllocator(in)) {
LOG_FATAL("ElfOpenFromMemory: NULL argument (contract violation)");
}- In
Elf.c:487:
MemSet(out, 0, sizeof(*out));
out->data = taken;
out->sections = VecInitT(out->sections, BufAllocator(&taken));
out->segments = VecInitT(out->segments, BufAllocator(&taken));
out->symbols = VecInitT(out->symbols, BufAllocator(&taken));- In
Elf.c:488:
out->data = taken;
out->sections = VecInitT(out->sections, BufAllocator(&taken));
out->segments = VecInitT(out->segments, BufAllocator(&taken));
out->symbols = VecInitT(out->symbols, BufAllocator(&taken));
out->dynamic_symbols = VecInitT(out->dynamic_symbols, BufAllocator(&taken));- In
Elf.c:489:
out->sections = VecInitT(out->sections, BufAllocator(&taken));
out->segments = VecInitT(out->segments, BufAllocator(&taken));
out->symbols = VecInitT(out->symbols, BufAllocator(&taken));
out->dynamic_symbols = VecInitT(out->dynamic_symbols, BufAllocator(&taken));- In
Elf.c:490:
out->segments = VecInitT(out->segments, BufAllocator(&taken));
out->symbols = VecInitT(out->symbols, BufAllocator(&taken));
out->dynamic_symbols = VecInitT(out->dynamic_symbols, BufAllocator(&taken));
if (!elf_decode_header(out))
Last updated on