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 /sal/rtl | |
parent | 04ae3d0cc9b671729deabf33c2cea1031d72e6ae (diff) |
Introduce OStringBuffer::appendUninitialized
...corresponding to the OUStringBuffer couterpart
Change-Id: I3ab03343696e6755cf1ccc470e4decc2f41d2558
Diffstat (limited to 'sal/rtl')
-rw-r--r-- | sal/rtl/math.cxx | 2 | ||||
-rw-r--r-- | sal/rtl/strbuf.cxx | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx index ac5a79387617..d74f5020bc1a 100644 --- a/sal/rtl/math.cxx +++ b/sal/rtl/math.cxx @@ -222,6 +222,7 @@ struct StringTraits sal_Int32 * pOffset, sal_Char const * pChars, sal_Int32 nLen) { + assert(pChars != nullptr); rtl_stringbuffer_insert(pBuffer, pCapacity, *pOffset, pChars, nLen); *pOffset += nLen; } @@ -230,6 +231,7 @@ struct StringTraits sal_Int32 * pOffset, sal_Char const * pStr, sal_Int32 nLen) { + assert(pStr != nullptr); rtl_stringbuffer_insert(pBuffer, pCapacity, *pOffset, pStr, nLen); *pOffset += nLen; } diff --git a/sal/rtl/strbuf.cxx b/sal/rtl/strbuf.cxx index f8b1f9c6df8c..f75d0cc7ef57 100644 --- a/sal/rtl/strbuf.cxx +++ b/sal/rtl/strbuf.cxx @@ -114,11 +114,14 @@ void SAL_CALL rtl_stringbuffer_insert( rtl_String ** This, memmove( pBuf + offset + len, pBuf + offset, n * sizeof(sal_Char) ); /* insert the new characters */ - if( len == 1 ) + if( str != nullptr ) + { + if( len == 1 ) /* optimized for 1 character */ - pBuf[offset] = *str; - else - memcpy( pBuf + offset, str, len * sizeof(sal_Char) ); + pBuf[offset] = *str; + else + memcpy( pBuf + offset, str, len * sizeof(sal_Char) ); + } (*This)->length = nOldLen + len; pBuf[ nOldLen + len ] = 0; } |