From 757a5b58e8f50ea66db425c8f45da31b0dbaa962 Mon Sep 17 00:00:00 2001 From: Pierre Curto Date: Tue, 3 Oct 2023 00:32:56 +0200 Subject: [PATCH] std::core::dstring: fix DString.zstr() (#1024) rename DString.zstr to DString.zstr_view --- lib/std/core/dstring.c3 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/std/core/dstring.c3 b/lib/std/core/dstring.c3 index 27c0114a4..c9bd51574 100644 --- a/lib/std/core/dstring.c3 +++ b/lib/std/core/dstring.c3 @@ -56,13 +56,14 @@ fn DString DString.new_concat(self, DString b, Allocator* using = mem::heap()) fn DString DString.new_tconcat(self, DString b) => self.new_concat(b, mem::temp()); -fn ZString DString.zstr(self) +fn ZString DString.zstr_view(&self) { StringData* data = self.data(); if (!data) return ""; if (data.capacity == data.len) { self.reserve(1); + data = self.data(); data.chars[data.len] = 0; } else if (data.chars[data.len] != 0) @@ -284,7 +285,7 @@ fn void DString.append_char(&self, char c) *self = new_with_capacity(MIN_CAPACITY); } self.reserve(1); - StringData* data = (StringData*)*self; + StringData* data = self.data(); data.chars[data.len++] = c; }