StrReserve
Description
Reserve enough capacity to fit at least n characters without further allocation. Does not change the string length. See VecReserve for the full SUCCESS/FAILURE contract.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:1132:
if (file_len > 0) {
StrReserve(&buffer, (u64)file_len);
i64 got = FileRead(file, StrBegin(&buffer), (u64)file_len);
if (got < 0) {- In
BitVec.c:843:
}
if (!StrReserve(out, bv->length + 1)) {
return false;
}- In
Str.c:101:
}
if (!StrReserve(out, len)) {
return false;
}- In
ProcMaps.c:192:
while (true) {
u64 grown_to = StrLen(&out->raw) + CHUNK + 1;
if (!StrReserve(&out->raw, grown_to)) {
LOG_ERROR("ProcMapsLoad: failed to grow buffer");
FileClose(&f);- In
Str.Memory.c:26:
// Reserve more space than needed
StrReserve(&s, 100);
// Add some data
- In
Str.Memory.c:101:
// Test StrReserve function
bool test_str_reserve(void) {
WriteFmt("Testing StrReserve\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Str.Memory.c:108:
// Reserve more space
StrReserve(&s, 100);
// Capacity should now be at least 100
- In
Str.Memory.c:117:
// Reserve less space (should be a no-op)
StrReserve(&s, 50);
// Capacity should still be at least 100
Last updated on