Make big_string pod (#1204)

`big_string` is not pod which means it needs to be properly constructed
and destroyed. Instead make it POD and destroy it manually in `string`
destructor.
This commit is contained in:
Alkis Evlogimenos 2024-06-08 19:02:33 +02:00 committed by GitHub
parent d44a7dc603
commit a0410f0170
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 21 deletions

View file

@ -23,27 +23,19 @@
namespace ctl {
namespace __ {
big_string::~big_string() /* noexcept */
{
if (n) {
if (n >= c)
__builtin_trap();
if (p[n])
__builtin_trap();
}
if (c && !p)
__builtin_trap();
free(p);
}
} // namespace __
string::~string() /* noexcept */
string::~string() noexcept
{
if (isbig()) {
big()->~big_string();
auto* b = big();
if (b->n) {
if (b->n >= b->c)
__builtin_trap();
if (b->p[b->n])
__builtin_trap();
}
if (b->c && !b->p)
__builtin_trap();
free(b->p);
}
}

View file

@ -38,8 +38,6 @@ struct big_string
size_t c : sizeof(size_t) * 8 - 1;
size_t big : 1 /* = 1 */;
#endif
~big_string() /* noexcept */;
};
} // namespace __