Skip to content

Commit 2dd3c44

Browse files
committed
std: remove a malloc from os::fill_charp_buf
1 parent 31b77ae commit 2dd3c44

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/libstd/os.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ pub fn getcwd() -> Path {
8787

8888
// FIXME: move these to str perhaps? #2620
8989

90-
pub fn fill_charp_buf(f: &fn(*mut c_char, size_t) -> bool)
91-
-> Option<~str> {
92-
let mut buf = vec::from_elem(TMPBUF_SZ, 0u8 as c_char);
90+
pub fn fill_charp_buf(f: &fn(*mut c_char, size_t) -> bool) -> Option<~str> {
91+
let mut buf = [0 as c_char, .. TMPBUF_SZ];
9392
do buf.as_mut_buf |b, sz| {
9493
if f(b, sz as size_t) {
9594
unsafe {

0 commit comments

Comments
 (0)