StrCapacity
Description
Capacity in characters: the most the string can hold before the next reallocation. Always >= StrLen(str).
Parameters
| Name | Direction | Description |
|---|---|---|
str |
in | String to query. |
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Str.Init.c:189:
// Check capacity is as expected
if (StrCapacity(&stack_str) != 20) {
result = false;
}- In
Str.Init.c:195:
// After the scope, stack_str should be zeroed out
if (StrBegin(&stack_str) != NULL || StrLen(&stack_str) != 0 || StrCapacity(&stack_str) != 0) {
result = false;
}- In
Str.Memory.c:32:
// Original capacity should be at least 100
bool result = (StrCapacity(&s) >= 100);
// Try to reduce space
- In
Str.Memory.c:38:
// Capacity should now be closer to the actual length
result = result && (StrCapacity(&s) < 100) && (StrCapacity(&s) >= StrLen(&s));
StrDeinit(&s);- In
Str.Memory.c:111:
// Capacity should now be at least 100
bool result = (StrCapacity(&s) >= 100);
// Length should still be 0
- In
Str.Memory.c:120:
// Capacity should still be at least 100
result = result && (StrCapacity(&s) >= 100);
StrDeinit(&s);- In
Str.Memory.c:142:
// Length should now be 0, but capacity should remain
result = result && (StrLen(&s) == 0) && (StrCapacity(&s) >= 13);
// Data pointer should still be valid
- In
File.c:91:
Zstr expected = "this is longer than the initial buffer";
bool result = (got == (i64)ZstrLen(expected)) && (StrLen(&body) == (size)ZstrLen(expected)) &&
ZstrCompare(StrBegin(&body), expected) == 0 && StrCapacity(&body) >= StrLen(&body) + 1;
StrDeinit(&body);
Last updated on