| 61 | } |
| 62 | |
| 63 | void OutputStream::bind_buffer(Buffer *buffer) { |
| 64 | Buffer *next = buffer == nullptr ? buffer_.get() : buffer; |
| 65 | if (active_buffer_ == next) { |
| 66 | return; |
| 67 | } |
| 68 | if (active_buffer_ != nullptr && active_buffer_ != buffer_.get()) { |
| 69 | // Rebinding must detach the previous external buffer to avoid stale |
| 70 | // backlinks that can trigger misdirected flushes and dangling pointers. |
| 71 | active_buffer_->output_stream_ = nullptr; |
| 72 | } |
| 73 | active_buffer_ = next; |
| 74 | } |
| 75 | |
| 76 | void OutputStream::unbind_buffer(Buffer *buffer) { |
| 77 | if (active_buffer_ == buffer) { |
no test coverage detected