From c30caae30bc64974eeaa1e81aa2abdc203f5120d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 7 Jan 2010 13:47:06 +0200 Subject: Overload attach() to accept size --- libxsde/xsde/cxx/string.hxx | 3 +++ libxsde/xsde/cxx/string.ixx | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libxsde/xsde/cxx/string.hxx b/libxsde/xsde/cxx/string.hxx index 807cfbd..365b855 100644 --- a/libxsde/xsde/cxx/string.hxx +++ b/libxsde/xsde/cxx/string.hxx @@ -77,6 +77,9 @@ namespace xsde void attach (char*); + void + attach (char*, size_t); + private: string (const string&); diff --git a/libxsde/xsde/cxx/string.ixx b/libxsde/xsde/cxx/string.ixx index bfae885..ce479bb 100644 --- a/libxsde/xsde/cxx/string.ixx +++ b/libxsde/xsde/cxx/string.ixx @@ -34,11 +34,17 @@ namespace xsde inline void string:: attach (char* s) { + attach (s, s != 0 ? strlen (s) : 0); + } + + inline void string:: + attach (char* s, size_t n) + { delete[] data_; data_ = s; - size_ = (s != 0 ? strlen (s) : 0); - capacity_ = (s != 0 ? size_ + 1 : 0); + size_ = n; + capacity_ = n + 1; } inline string::error string:: @@ -146,4 +152,3 @@ namespace xsde } } } - -- cgit v1.1