From d537da41d7b51783f98e0629917dc3831b053795 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Fri, 30 Mar 2012 16:53:45 +0200 Subject: no bad_alloc throwing in string literal O(U)String functions String literals should be reasonably short, and if memory is so low that they trigger allocation failure, something else would would trip over very soon anyway. --- sal/inc/rtl/ustring.hxx | 23 ----------------------- sal/rtl/source/strtmpl.cxx | 2 +- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index ad6fad22713e..a5528894e0d4 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -192,7 +192,6 @@ public: @param literal the 8-bit ASCII string literal - @exception std::bad_alloc is thrown if an out-of-memory condition occurs @since LibreOffice 3.6 */ #ifdef HAVE_SFINAE_ANONYMOUS_BROKEN @@ -203,13 +202,6 @@ public: { pData = 0; rtl_uString_newFromLiteral( &pData, literal, N - 1 ); - if (pData == 0) { -#if defined EXCEPTIONS_OFF - SAL_WARN("sal", "std::bad_alloc but EXCEPTIONS_OFF"); -#else - throw std::bad_alloc(); -#endif - } #ifdef RTL_STRING_UNITTEST rtl_string_unittest_const_literal = true; #endif @@ -237,13 +229,6 @@ public: { pData = 0; rtl_uString_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1 ); - if (pData == 0) { -#if defined EXCEPTIONS_OFF - SAL_WARN("sal", "std::bad_alloc but EXCEPTIONS_OFF"); -#else - throw std::bad_alloc(); -#endif - } #ifdef RTL_STRING_UNITTEST rtl_string_unittest_const_literal = true; #endif @@ -379,20 +364,12 @@ public: @param literal the 8-bit ASCII string literal - @exception std::bad_alloc is thrown if an out-of-memory condition occurs @since LibreOffice 3.6 */ template< typename T > typename internal::ConstCharArrayDetector< T, OUString& >::Type operator=( T& literal ) { rtl_uString_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1 ); - if (pData == 0) { -#if defined EXCEPTIONS_OFF - SAL_WARN("sal", "std::bad_alloc but EXCEPTIONS_OFF"); -#else - throw std::bad_alloc(); -#endif - } return *this; } diff --git a/sal/rtl/source/strtmpl.cxx b/sal/rtl/source/strtmpl.cxx index 026d6473b6d1..8e1de8bdab0f 100644 --- a/sal/rtl/source/strtmpl.cxx +++ b/sal/rtl/source/strtmpl.cxx @@ -1218,7 +1218,7 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newFromLiteral)( IMPL_RTL_STRINGDATA** ppThis IMPL_RTL_STRINGNAME( release )( *ppThis ); *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); - OSL_ASSERT(*ppThis != NULL); + assert( *ppThis != NULL ); if ( (*ppThis) ) { IMPL_RTL_STRCODE* pBuffer = (*ppThis)->buffer; -- cgit