mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-03 08:20:28 +00:00
Tweak reserve
It clamps to size() + 1, not just size(), i.e. we reserve the null byte. We also check the exact requested capacity against the sso_max before we do the (??) alignment (??) stuff.
This commit is contained in:
parent
731bdf7a06
commit
2d55834eaf
1 changed files with 4 additions and 4 deletions
|
@ -89,13 +89,13 @@ string::reserve(size_t c2) noexcept
|
|||
{
|
||||
char* p2;
|
||||
size_t n = size();
|
||||
if (c2 < n)
|
||||
c2 = n;
|
||||
if (c2 < n + 1)
|
||||
c2 = n + 1;
|
||||
if (c2 <= __::string_size)
|
||||
return;
|
||||
if (ckd_add(&c2, c2, 15))
|
||||
__builtin_trap();
|
||||
c2 &= -16;
|
||||
if (c2 <= __::sso_max)
|
||||
return;
|
||||
if (!isbig()) {
|
||||
if (!(p2 = (char*)malloc(c2)))
|
||||
__builtin_trap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue