diff options
author | Steve Huston <shuston@riverace.com> | 2006-11-22 22:02:38 +0000 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 2006-11-22 22:02:38 +0000 |
commit | 011181470ce99a9c6522f4ae343e3ffee7503186 (patch) | |
tree | 727adde8442af1a0c0c270a537e026fc0caffdd9 /ACE/ace/String_Base.cpp | |
parent | eaecbaca808c1f046c7d87e66564cffc3809f133 (diff) | |
download | ATCD-011181470ce99a9c6522f4ae343e3ffee7503186.tar.gz |
ChangeLogTag:Wed Nov 22 21:58:16 UTC 2006 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ACE/ace/String_Base.cpp')
-rw-r--r-- | ACE/ace/String_Base.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/ACE/ace/String_Base.cpp b/ACE/ace/String_Base.cpp index 01de0963b72..525dcbc2553 100644 --- a/ACE/ace/String_Base.cpp +++ b/ACE/ace/String_Base.cpp @@ -267,19 +267,29 @@ ACE_String_Base<CHAR>::resize (typename ACE_String_Base<CHAR>::size_type len, { ACE_TRACE ("ACE_String_Base<CHAR>::resize"); + fast_resize(len); + ACE_OS::memset (this->rep_, c, this->buf_len_ * sizeof (CHAR)); +} + +template <class CHAR> void +ACE_String_Base<CHAR>::fast_resize (size_t len) +{ + ACE_TRACE ("ACE_String_Base<CHAR>::fast_resize"); + // Only reallocate if we don't have enough space... if (this->buf_len_ <= len) { - if (this->buf_len_ != 0 && this->release_ != 0) + if (this->buf_len_ != 0 && this->release_ != 0) this->allocator_->free (this->rep_); - this->rep_ = static_cast<CHAR*>( - this->allocator_->malloc ((len + 1) * sizeof (CHAR))); + this->rep_ = static_cast<CHAR*> + (this->allocator_->malloc ((len + 1) * sizeof (CHAR))); this->buf_len_ = len + 1; this->release_ = 1; } this->len_ = 0; - ACE_OS::memset (this->rep_, c, this->buf_len_ * sizeof (CHAR)); + if (len > 0) + this->rep_[0] = 0; } template <class CHAR> void |