diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-01-07 13:47:06 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-01-07 13:47:06 +0200 |
commit | c30caae30bc64974eeaa1e81aa2abdc203f5120d (patch) | |
tree | 19de6a7c91e99366b681e3314bb24bc1ed5a5766 | |
parent | 94ddce449c9aa8fb439e1da7d29ad1072cc92be6 (diff) |
Overload attach() to accept size
-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 } } } - |