Skip to content

Commit

Permalink
strconv: mark strconv.v_sprintf and strconv.v_printf with [unsafe] (p…
Browse files Browse the repository at this point in the history
…art 2, breaking change, needed an update to vsl) (#18836)
  • Loading branch information
spytheman committed Jul 10, 2023
1 parent 6b00685 commit acd581a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions vlib/strconv/vprintf.c.v
Expand Up @@ -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`.
Expand All @@ -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 {
Expand Down

0 comments on commit acd581a

Please sign in to comment.