From bdc56c7d0b981b54d8173763ac33264b1d501eb1 Mon Sep 17 00:00:00 2001 From: mertcandav Date: Sat, 3 Aug 2024 11:46:10 +0300 Subject: [PATCH] api: fix rune handling of strings --- api/str.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/str.hpp b/api/str.hpp index 90eb82536..874adb994 100644 --- a/api/str.hpp +++ b/api/str.hpp @@ -56,6 +56,7 @@ namespace jule static jule::Str from_rune(const jule::I32 r) noexcept { jule::Str s; + s._len = 0; s.buffer = jule::Str::buffer_t::make(jule::Str::alloc(4)); s._slice = s.buffer.alloc; jule::utf8_push_rune_bytes(r, s); @@ -99,8 +100,8 @@ namespace jule Str(const jule::Slice &src) { - this->_len = src.len() << 2; - this->buffer = jule::Str::buffer_t::make(jule::Str::alloc(this->_len)); + this->_len = 0; + this->buffer = jule::Str::buffer_t::make(jule::Str::alloc(src.len() << 2)); this->_slice = this->buffer.alloc; for (const jule::I32 &r : src) jule::utf8_push_rune_bytes(r, *this);