diff options
-rw-r--r-- | libxsde/xsde/cxx/string.hxx | 3 | ||||
-rw-r--r-- | 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 } } } - |