crush compiler warnings and handle out of memory errors slightly better

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29819 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ryan Norton
2004-10-13 02:54:32 +00:00
parent 42f25dcfc7
commit 49dcf8bfb8

View File

@@ -1133,12 +1133,16 @@ wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength)
size_t nActualLength = wxWcstr(buffer, psz, nLen, conv); size_t nActualLength = wxWcstr(buffer, psz, nLen, conv);
if ( !Alloc(nActualLength + 1) ) if ( !Alloc(nActualLength + 1) )
{
wxFAIL_MSG(wxT("Out of memory in wxString")); wxFAIL_MSG(wxT("Out of memory in wxString"));
}
else
{
//Copy the data //Copy the data
assign(buffer.data(), nActualLength); assign(buffer.data(), nActualLength);
} }
} }
}
//Convert wxString in Unicode mode to a multi-byte string //Convert wxString in Unicode mode to a multi-byte string
const wxCharBuffer wxString::mb_str(wxMBConv& conv) const const wxCharBuffer wxString::mb_str(wxMBConv& conv) const
@@ -1198,12 +1202,16 @@ wxString::wxString(const wchar_t *pwz, wxMBConv& conv, size_t nLength)
size_t nActualLength = wxMbstr(buffer, pwz, nLen, conv); size_t nActualLength = wxMbstr(buffer, pwz, nLen, conv);
if ( !Alloc(nActualLength + 1) ) if ( !Alloc(nActualLength + 1) )
{
wxFAIL_MSG(wxT("Out of memory in wxString")); wxFAIL_MSG(wxT("Out of memory in wxString"));
}
else
{
//copy the data //copy the data
assign(buffer.data(), nActualLength); assign(buffer.data(), nActualLength);
} }
} }
}
//Converts this string to a wide character string if unicode //Converts this string to a wide character string if unicode
//mode is not enabled and wxUSE_WCHAR_T is enabled //mode is not enabled and wxUSE_WCHAR_T is enabled