From acd581add5710bc71179b70e6aaa776e630c1449 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 10 Jul 2023 21:20:47 +0300 Subject: [PATCH] strconv: mark strconv.v_sprintf and strconv.v_printf with [unsafe] (part 2, breaking change, needed an update to vsl) (#18836) --- vlib/strconv/vprintf.c.v | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vlib/strconv/vprintf.c.v b/vlib/strconv/vprintf.c.v index 4d99c14d13..187c93e5e3 100644 --- a/vlib/strconv/vprintf.c.v +++ b/vlib/strconv/vprintf.c.v @@ -27,8 +27,9 @@ enum Char_parse_state { // Note, that this function is unsafe. // In most cases, you are better off using V's string interpolation, // when your format string is known at compile time. -fn v_printf(str string, pt ...voidptr) { - print(v_sprintf(str, ...pt)) +[unsafe] +pub fn v_printf(str string, pt ...voidptr) { + print(unsafe { v_sprintf(str, ...pt) }) } // v_sprintf returns a sprintf-like formated `string`. @@ -41,7 +42,7 @@ fn v_printf(str string, pt ...voidptr) { // x := 3.141516 // assert strconv.v_sprintf('aaa %G', x) == 'aaa 3.141516' // ``` -[direct_array_access; manualfree] +[direct_array_access; manualfree; unsafe] pub fn v_sprintf(str string, pt ...voidptr) string { mut res := strings.new_builder(pt.len * 16) defer {