From 9a0ec7f367e18a34dc519134bff100f2a613865a Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 2 Jun 2022 10:41:27 +0300 Subject: [PATCH] strings: update docs for .str() and for .free() --- vlib/strings/builder.c.v | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/vlib/strings/builder.c.v b/vlib/strings/builder.c.v index be216c997d..dcdc5e2957 100644 --- a/vlib/strings/builder.c.v +++ b/vlib/strings/builder.c.v @@ -172,12 +172,9 @@ pub fn (b &Builder) after(n int) string { } // str returns a copy of all of the accumulated buffer content. -// Note: after a call to b.str(), the builder b should not be -// used again, you need to call b.free() first, or just leave -// it to be freed by -autofree when it goes out of scope. -// The returned string *owns* its own separate copy of the -// accumulated data that was in the string builder, before the -// .str() call. +// Note: after a call to b.str(), the builder b will be empty, and could be used again. +// The returned string *owns* its own separate copy of the accumulated data that was in +// the string builder, before the .str() call. pub fn (mut b Builder) str() string { b << u8(0) bcopy := unsafe { &u8(memdup_noscan(b.data, b.len)) } @@ -208,7 +205,8 @@ pub fn (mut b Builder) ensure_cap(n int) { } } -// free is for manually freeing the contents of the buffer +// free frees the memory block, used for the buffer. +// Note: do not use the builder, after a call to free(). [unsafe] pub fn (mut b Builder) free() { if b.data != 0 {