Skip to content

Commit acd581a

Browse files
authored
strconv: mark strconv.v_sprintf and strconv.v_printf with [unsafe] (part 2, breaking change, needed an update to vsl) (#18836)
1 parent 6b00685 commit acd581a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

vlib/strconv/vprintf.c.v

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ enum Char_parse_state {
2727
// Note, that this function is unsafe.
2828
// In most cases, you are better off using V's string interpolation,
2929
// when your format string is known at compile time.
30-
fn v_printf(str string, pt ...voidptr) {
31-
print(v_sprintf(str, ...pt))
30+
[unsafe]
31+
pub fn v_printf(str string, pt ...voidptr) {
32+
print(unsafe { v_sprintf(str, ...pt) })
3233
}
3334

3435
// v_sprintf returns a sprintf-like formated `string`.
@@ -41,7 +42,7 @@ fn v_printf(str string, pt ...voidptr) {
4142
// x := 3.141516
4243
// assert strconv.v_sprintf('aaa %G', x) == 'aaa 3.141516'
4344
// ```
44-
[direct_array_access; manualfree]
45+
[direct_array_access; manualfree; unsafe]
4546
pub fn v_sprintf(str string, pt ...voidptr) string {
4647
mut res := strings.new_builder(pt.len * 16)
4748
defer {

0 commit comments

Comments
 (0)