| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "nacl_io/fifo_char.h" | 5 #include "nacl_io/fifo_char.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 | 11 |
| 12 namespace nacl_io { | 12 namespace nacl_io { |
| 13 | 13 |
| 14 FIFOChar::FIFOChar(size_t size) | 14 FIFOChar::FIFOChar(size_t size) |
| 15 : buffer_(NULL), | 15 : buffer_(NULL), size_(size), avail_(0), tail_(0) { |
| 16 size_(size), | |
| 17 avail_(0), | |
| 18 tail_(0) { | |
| 19 if (size) | 16 if (size) |
| 20 buffer_ = new char[size]; | 17 buffer_ = new char[size]; |
| 21 } | 18 } |
| 22 | 19 |
| 23 FIFOChar::~FIFOChar() { | 20 FIFOChar::~FIFOChar() { |
| 24 delete[] buffer_; | 21 delete[] buffer_; |
| 25 } | 22 } |
| 26 | 23 |
| 27 bool FIFOChar::IsEmpty() { | 24 bool FIFOChar::IsEmpty() { |
| 28 return avail_ == 0; | 25 return avail_ == 0; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 104 |
| 108 out += write_len; | 105 out += write_len; |
| 109 len -= write_len; | 106 len -= write_len; |
| 110 } | 107 } |
| 111 | 108 |
| 112 avail_ += out; | 109 avail_ += out; |
| 113 return out; | 110 return out; |
| 114 } | 111 } |
| 115 | 112 |
| 116 } // namespace nacl_io | 113 } // namespace nacl_io |
| OLD | NEW |