Replace sprintf with rust fmt

This commit is contained in:
David Tolnay 2022-07-03 20:05:55 -07:00
parent f0110f61b4
commit 64531de7a9
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82

View file

@ -1,8 +1,9 @@
use crate::externs::__assert_fail;
use crate::libc;
use crate::yaml::*;
use std::io::Write;
use std::slice;
extern "C" {
fn sprintf(_: *mut libc::c_char, _: *const libc::c_char, _: ...) -> libc::c_int;
fn yaml_malloc(size: size_t) -> *mut libc::c_void;
fn yaml_free(ptr: *mut libc::c_void);
fn yaml_emitter_emit(
@ -421,11 +422,8 @@ unsafe extern "C" fn yaml_emitter_generate_anchor(
if anchor.is_null() {
return 0 as *mut yaml_char_t;
}
sprintf(
anchor as *mut libc::c_char,
b"id%03d\0" as *const u8 as *const libc::c_char,
anchor_id,
);
let mut buffer = slice::from_raw_parts_mut(anchor.cast(), 16);
let _ = write!(buffer, "id{:03}\0", anchor_id);
return anchor;
}
unsafe extern "C" fn yaml_emitter_dump_node(