Skip to content

Commit

Permalink
Fix windows build error. buf is borrowed by the call to
Browse files Browse the repository at this point in the history
`as_mut_buf()` and so we must invoke `slice()` outside of that
call.
  • Loading branch information
nikomatsakis authored and Nick Desaulniers committed Feb 15, 2013
1 parent 5d62a4a commit 91af527
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/libcore/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,24 @@ pub mod win32 {
let mut res = None;
let mut done = false;
while !done {
let mut buf = vec::from_elem(n as uint, 0u16);
let mut k: DWORD = 0;
let buf = vec::cast_to_mut(vec::from_elem(n as uint, 0u16));
do vec::as_mut_buf(buf) |b, _sz| {
let k : DWORD = f(b, TMPBUF_SZ as DWORD);
k = f(b, TMPBUF_SZ as DWORD);
if k == (0 as DWORD) {
done = true;
} else if (k == n &&
libc::GetLastError() ==
libc::ERROR_INSUFFICIENT_BUFFER as DWORD) {
n *= (2 as DWORD);
} else {
let sub = vec::slice(buf, 0u, k as uint);
res = option::Some(str::from_utf16(sub));
done = true;
}
}
if k != 0 && done {
let sub = vec::slice(buf, 0u, k as uint);
res = option::Some(str::from_utf16(sub));
}
}
return res;
}
Expand Down

5 comments on commit 91af527

@bors
Copy link
Contributor

@bors bors commented on 91af527 Feb 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at nickdesaulniers@91af527

@bors
Copy link
Contributor

@bors bors commented on 91af527 Feb 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nickdesaulniers/rust/issue3869 = 91af527 into auto

@bors
Copy link
Contributor

@bors bors commented on 91af527 Feb 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nickdesaulniers/rust/issue3869 = 91af527 merged ok, testing candidate = 566bcf2

@bors
Copy link
Contributor

@bors bors commented on 91af527 Feb 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 91af527 Feb 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 566bcf2

Please sign in to comment.