From 186990395d72a803dd4a9f087fe4e05f49e69ad2 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 20 Nov 2014 07:44:43 +0100 Subject: Clean up Mac _imp_getProcessLocale Introduces OUStringBuffer::appendUninitialized. Change-Id: If225ec4d798e0df91cad60130e3f22ee26b88abb --- include/rtl/ustrbuf.h | 4 +++- include/rtl/ustrbuf.hxx | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'include/rtl') diff --git a/include/rtl/ustrbuf.h b/include/rtl/ustrbuf.h index e81d40ba1c75..adaf92d2d4cb 100644 --- a/include/rtl/ustrbuf.h +++ b/include/rtl/ustrbuf.h @@ -100,7 +100,9 @@ SAL_DLLPUBLIC void SAL_CALL rtl_uStringbuffer_ensureCapacity( @param This The string, on that the operation should take place @param capacity the capacity of the string buffer @param offset the offset. - @param str a character array. + @param str a character array. Since LibreOffice 4.4, as a special + case, if str is null then the len added characters are + left uninitialized. @param len the number of characters to append. */ SAL_DLLPUBLIC void SAL_CALL rtl_uStringbuffer_insert( diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx index 64c26cff3424..8bba42921fbc 100644 --- a/include/rtl/ustrbuf.hxx +++ b/include/rtl/ustrbuf.hxx @@ -474,6 +474,7 @@ public: OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len) { assert( len >= 0 ); + assert( len == 0 || str != 0 ); rtl_uStringbuffer_insert( &pData, &nCapacity, getLength(), str, len ); return *this; } @@ -733,6 +734,28 @@ public: return insertUtf32(getLength(), c); } + /** + Unsafe way to make space for a fixed amount of characters to be appended + into this OUStringBuffer. + + A call to this function must immediately be followed by code that + completely fills the uninitialized block pointed to by the return value. + + @param length the length of the uninitialized block of sal_Unicode + entities; must be non-negative + + @return a pointer to the start of the uninitialized block; only valid + until this OUStringBuffer's capacity changes + + @since LibreOffice 4.4 + */ + sal_Unicode * appendUninitialized(sal_Int32 length) { + assert(length >= 0); + sal_Int32 n = getLength(); + rtl_uStringbuffer_insert(&pData, &nCapacity, n, 0, length); + return pData->buffer + n; + } + /** Inserts the string into this string buffer. @@ -797,6 +820,7 @@ public: { assert( offset >= 0 && offset <= pData->length ); assert( len >= 0 ); + assert( len == 0 || str != 0 ); rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len ); return *this; } -- cgit