added length to wx(Scoped)CharBuffer to improve handling of embedded NULs

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59927 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2009-03-29 20:58:39 +00:00
parent d792823395
commit 6df09f32fd
7 changed files with 87 additions and 34 deletions

View File

@@ -1637,7 +1637,7 @@ public:
if ( len )
*len = length();
return wxCharTypeBuffer<T>::CreateNonOwned(wx_str());
return wxCharTypeBuffer<T>::CreateNonOwned(wx_str(), length());
#endif // Unicode build kind
}
@@ -3540,9 +3540,10 @@ struct wxStringAsBufHelper<wchar_t>
{
static wxScopedWCharBuffer Get(const wxString& s, size_t *len)
{
const size_t length = s.length();
if ( len )
*len = s.length();
return wxScopedWCharBuffer::CreateNonOwned(s.wx_str());
*len = length;
return wxScopedWCharBuffer::CreateNonOwned(s.wx_str(), length);
}
};
@@ -3553,9 +3554,10 @@ struct wxStringAsBufHelper<char>
{
static wxScopedCharBuffer Get(const wxString& s, size_t *len)
{
const size_t length = s.utf8_length();
if ( len )
*len = s.utf8_length();
return wxScopedCharBuffer::CreateNonOwned(s.wx_str());
*len = length;
return wxScopedCharBuffer::CreateNonOwned(s.wx_str(), length);
}
};