diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-11-20 08:32:37 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-11-20 08:34:07 +0100 |
commit | 5252652ac57b3358db6cc0d423cc3d67882b5e90 (patch) | |
tree | 1bf6e38df881b05f5ca80d13981478a1f137257e /include | |
parent | 04ae3d0cc9b671729deabf33c2cea1031d72e6ae (diff) |
Introduce OStringBuffer::appendUninitialized
...corresponding to the OUStringBuffer couterpart
Change-Id: I3ab03343696e6755cf1ccc470e4decc2f41d2558
Diffstat (limited to 'include')
-rw-r--r-- | include/rtl/strbuf.h | 4 | ||||
-rw-r--r-- | include/rtl/strbuf.hxx | 24 |
2 files changed, 27 insertions, 1 deletions
diff --git a/include/rtl/strbuf.h b/include/rtl/strbuf.h index 403d53c0b895..3f682db37615 100644 --- a/include/rtl/strbuf.h +++ b/include/rtl/strbuf.h @@ -101,7 +101,9 @@ SAL_DLLPUBLIC void SAL_CALL rtl_stringbuffer_ensureCapacity( @param[in,out] This the String to operate on. @param[in,out] capacity the capacity of the string buffer @param[in] offset the offset. - @param[in] str a character array. + @param[in] 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[in] len the number of characters to append. */ SAL_DLLPUBLIC void SAL_CALL rtl_stringbuffer_insert( diff --git a/include/rtl/strbuf.hxx b/include/rtl/strbuf.hxx index c089d61d48ad..b135298e1ced 100644 --- a/include/rtl/strbuf.hxx +++ b/include/rtl/strbuf.hxx @@ -490,6 +490,7 @@ public: OStringBuffer & append( const sal_Char * str, sal_Int32 len) { assert( len >= 0 ); + assert( len == 0 || str != 0 ); rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), str, len ); return *this; } @@ -645,6 +646,28 @@ public: } /** + Unsafe way to make space for a fixed amount of characters to be appended + into this OStringBuffer. + + 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 char entities; + must be non-negative + + @return a pointer to the start of the uninitialized block; only valid + until this OStringBuffer's capacity changes + + @since LibreOffice 4.4 + */ + char * appendUninitialized(sal_Int32 length) { + assert(length >= 0); + sal_Int32 n = getLength(); + rtl_stringbuffer_insert(&pData, &nCapacity, n, 0, length); + return pData->buffer + n; + } + + /** Inserts the string into this string buffer. The characters of the <code>String</code> argument are inserted, in @@ -729,6 +752,7 @@ public: { assert( offset >= 0 && offset <= pData->length ); assert( len >= 0 ); + assert( len == 0 || str != 0 ); rtl_stringbuffer_insert( &pData, &nCapacity, offset, str, len ); return *this; } |