| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "url/url_canon_stdstring.h" | 5 #include "url/url_canon_stdstring.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 |
| 7 namespace url { | 9 namespace url { |
| 8 | 10 |
| 9 StdStringCanonOutput::StdStringCanonOutput(std::string* str) | 11 StdStringCanonOutput::StdStringCanonOutput(std::string* str) |
| 10 : CanonOutput(), str_(str) { | 12 : CanonOutput(), str_(str) { |
| 11 cur_len_ = static_cast<int>(str_->size()); // Append to existing data. | 13 cur_len_ = static_cast<int>(str_->size()); // Append to existing data. |
| 12 str_->resize(str_->capacity()); | 14 str_->resize(str_->capacity()); |
| 13 buffer_ = str_->empty() ? NULL : &(*str_)[0]; | 15 buffer_ = str_->empty() ? NULL : &(*str_)[0]; |
| 14 buffer_len_ = static_cast<int>(str_->size()); | 16 buffer_len_ = static_cast<int>(str_->size()); |
| 15 } | 17 } |
| 16 | 18 |
| 17 StdStringCanonOutput::~StdStringCanonOutput() { | 19 StdStringCanonOutput::~StdStringCanonOutput() { |
| 18 // Nothing to do, we don't own the string. | 20 // Nothing to do, we don't own the string. |
| 19 } | 21 } |
| 20 | 22 |
| 21 void StdStringCanonOutput::Complete() { | 23 void StdStringCanonOutput::Complete() { |
| 22 str_->resize(cur_len_); | 24 str_->resize(cur_len_); |
| 23 buffer_len_ = cur_len_; | 25 buffer_len_ = cur_len_; |
| 24 } | 26 } |
| 25 | 27 |
| 26 void StdStringCanonOutput::Resize(int sz) { | 28 void StdStringCanonOutput::Resize(int sz) { |
| 27 str_->resize(sz); | 29 str_->resize(sz); |
| 28 buffer_ = str_->empty() ? NULL : &(*str_)[0]; | 30 buffer_ = str_->empty() ? NULL : &(*str_)[0]; |
| 29 buffer_len_ = sz; | 31 buffer_len_ = sz; |
| 30 } | 32 } |
| 31 | 33 |
| 32 } // namespace url | 34 } // namespace url |
| OLD | NEW |