BufResize
Description
Set b’s length to exactly n bytes, growing the backing store if necessary. New bytes are zero-initialized; existing bytes past n are dropped.
Success
Returns true; b->length == n. b->data may have moved when growing.
Failure
Returns false if the underlying allocator fails to grow the buffer; *b is unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Pe.c:552:
}
MemCopy(BufData(©), data, data_size);
BufResize(©, (size)data_size);
return PeOpenFromMemory(out, ©);
}- In
Pdb.c:740:
}
MemCopy(BufData(©), data, data_size);
BufResize(©, (size)data_size);
return PdbOpenFromMemory(out, ©);
}- In
MachO.c:457:
}
MemCopy(BufData(©), data, data_size);
BufResize(©, (size)data_size);
return MachoOpenFromMemory(out, ©);
}- In
Elf.c:519:
}
MemCopy(BufData(©), data, data_size);
BufResize(©, (size)data_size);
// Hand `©` to the L-form -- it consumes the local and zeros
// it. The local goes out of scope right after.
- In
File.c:823:
};
Buf src = BufInit(alloc_base);
bool ok = BufResize(&src, N);
for (i32 i = 0; i < N; ++i) {
BufData(&src)[i] = (u8)('A' + (i % 26));- In
File.c:931:
Buf in = BufInit(alloc_base);
bool ok = BufResize(&in, 5);
MemCopy(BufData(&in), "12345", 5);- In
Pdb.c:2401:
}
MemCopy(BufData(&in), sblob, sizeof(sblob));
BufResize(&in, (size)sizeof(sblob));
Pdb pdb;
Last updated on