Skip to content

Commit a9a5ef9

Browse files
committed
Use heap for stdout and stderr
Signed-off-by: Ayush Singh <[email protected]>
1 parent 14b288a commit a9a5ef9

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

library/std/src/sys/uefi/stdio.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use crate::mem::MaybeUninit;
44
use crate::os::uefi;
55
use crate::ptr::NonNull;
66

7-
const MAX_BUFFER_SIZE: usize = 8192;
8-
97
pub struct Stdin {
108
pending: Option<char>,
119
}
@@ -111,19 +109,14 @@ fn write(
111109
protocol: *mut r_efi::protocols::simple_text_output::Protocol,
112110
buf: &[u8],
113111
) -> io::Result<usize> {
114-
let mut utf16 = [0; MAX_BUFFER_SIZE / 2];
115-
116112
// Get valid UTF-8 buffer
117113
let utf8 = match crate::str::from_utf8(buf) {
118114
Ok(x) => x,
119115
Err(e) => unsafe { crate::str::from_utf8_unchecked(&buf[..e.valid_up_to()]) },
120116
};
121-
// Clip UTF-8 buffer to max UTF-16 buffer we support
122-
let utf8 = &utf8[..utf8.floor_char_boundary(utf16.len() - 1)];
123117

124-
for (i, ch) in utf8.encode_utf16().enumerate() {
125-
utf16[i] = ch;
126-
}
118+
let mut utf16: Vec<u16> = utf8.encode_utf16().collect();
119+
utf16.push(0);
127120

128121
unsafe { simple_text_output(protocol, &mut utf16) }?;
129122

0 commit comments

Comments
 (0)