Codechange: use smart pointers when creating StringIterators

This commit is contained in:
Rubidium
2023-01-13 17:55:43 +01:00
committed by rubidium42
parent b35c791d05
commit b951332def
6 changed files with 15 additions and 18 deletions

View File

@@ -369,13 +369,11 @@ bool Textbuf::MovePos(uint16 keycode)
* @param max_chars maximum size in chars, including terminating '\0'
*/
Textbuf::Textbuf(uint16 max_bytes, uint16 max_chars)
: buf(MallocT<char>(max_bytes))
: buf(MallocT<char>(max_bytes)), char_iter(StringIterator::Create())
{
assert(max_bytes != 0);
assert(max_chars != 0);
this->char_iter = StringIterator::Create();
this->afilter = CS_ALPHANUMERAL;
this->max_bytes = max_bytes;
this->max_chars = max_chars == UINT16_MAX ? max_bytes : max_chars;
@@ -385,7 +383,6 @@ Textbuf::Textbuf(uint16 max_bytes, uint16 max_chars)
Textbuf::~Textbuf()
{
delete this->char_iter;
free(this->buf);
}