aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-10-15 17:10:06 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-10-15 17:10:06 -0400
commitfca1d53625281f763f628fc8b2f41d22bef29c57 (patch)
tree92c5d7e5800a03734551ba091bdf2da28abb57c9 /std
parentfaf64b5d0fa53a4fcc5ac24aa2aada502937808b (diff)
downloadzig-fca1d53625281f763f628fc8b2f41d22bef29c57.tar.gz
zig-fca1d53625281f763f628fc8b2f41d22bef29c57.zip
std.io: fix bug when writing large buffer
Diffstat (limited to 'std')
-rw-r--r--std/io.zig9
1 files changed, 4 insertions, 5 deletions
diff --git a/std/io.zig b/std/io.zig
index 124e7714da..943f78e875 100644
--- a/std/io.zig
+++ b/std/io.zig
@@ -170,7 +170,8 @@ pub const OutStream = struct {
if (self.index == 0)
return;
- return self.unbufferedWrite(self.buffer[0..self.index]);
+ %return self.unbufferedWrite(self.buffer[0..self.index]);
+ self.index = 0;
}
pub fn close(self: &OutStream) {
@@ -216,12 +217,10 @@ pub const OutStream = struct {
fn unbufferedWrite(self: &OutStream, bytes: []const u8) -> %void {
if (is_posix) {
- %return os.posixWrite(self.fd, self.buffer[0..self.index]);
- self.index = 0;
+ %return os.posixWrite(self.fd, bytes);
} else if (is_windows) {
const handle = %return self.getHandle();
- %return os.windowsWrite(handle, self.buffer[0..self.index]);
- self.index = 0;
+ %return os.windowsWrite(handle, bytes);
} else {
@compileError("Unsupported OS");
}