summaryrefslogtreecommitdiff
path: root/include/rtl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-11-20 08:32:37 +0100
committerStephan Bergmann <sbergman@redhat.com>2014-11-20 08:34:07 +0100
commit5252652ac57b3358db6cc0d423cc3d67882b5e90 (patch)
tree1bf6e38df881b05f5ca80d13981478a1f137257e /include/rtl
parent04ae3d0cc9b671729deabf33c2cea1031d72e6ae (diff)
Introduce OStringBuffer::appendUninitialized
...corresponding to the OUStringBuffer couterpart Change-Id: I3ab03343696e6755cf1ccc470e4decc2f41d2558
Diffstat (limited to 'include/rtl')
-rw-r--r--include/rtl/strbuf.h4
-rw-r--r--include/rtl/strbuf.hxx24
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;
}