Kaydet (Commit) 13d277b5 authored tarafından Luboš Luňák's avatar Luboš Luňák

fix capacity in stringbuffers

rtl_stringbuffer_* functions silently allocate +16 extra for capacity,
but rtl_string_* functions do not. As intuitive and obvious as ever.

Change-Id: Ia0bb63dedf31f6ad5c687187221d7385043b5456
üst 371443a8
......@@ -229,11 +229,12 @@ public:
{
const int l = c.length();
rtl_String* buffer = NULL;
rtl_string_new_WithLength( &buffer, l );
nCapacity = l + 16;
rtl_string_new_WithLength( &buffer, nCapacity );
char* end = c.addData( buffer->buffer );
*end = '\0';
buffer->length = end - buffer->buffer;
pData = buffer;
nCapacity = l + 16;
}
#endif
......
......@@ -221,12 +221,13 @@ public:
{
const int l = c.length();
rtl_uString* buffer = NULL;
rtl_uString_new_WithLength( &buffer, l ); // TODO this clears, not necessary
nCapacity = l + 16;
rtl_uString_new_WithLength( &buffer, nCapacity ); // TODO this clears, not necessary
sal_Unicode* end = c.addData( buffer->buffer );
*end = '\0';
buffer->length = end - buffer->buffer;
// TODO realloc in case buffer->length is noticeably smaller than l ?
pData = buffer;
nCapacity = l + 16;
}
#endif
/** Assign to this a copy of value.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment