summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i18npool/source/characterclassification/cclass_unicode.cxx2
-rw-r--r--i18npool/source/nativenumber/nativenumbersupplier.cxx5
-rw-r--r--i18npool/source/textconversion/textconversion_zh.cxx4
-rw-r--r--i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx6
-rw-r--r--i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx6
-rw-r--r--i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx6
-rw-r--r--i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx6
-rw-r--r--i18npool/source/transliteration/transliteration_Ignore.cxx6
-rw-r--r--i18npool/source/transliteration/transliteration_Numeric.cxx2
-rw-r--r--i18npool/source/transliteration/transliteration_OneToOne.cxx6
-rw-r--r--i18npool/source/transliteration/transliteration_body.cxx4
-rw-r--r--i18nutil/inc/i18nutil/x_rtl_ustring.h22
-rw-r--r--i18nutil/source/utility/widthfolding.cxx11
13 files changed, 47 insertions, 39 deletions
diff --git a/i18npool/source/characterclassification/cclass_unicode.cxx b/i18npool/source/characterclassification/cclass_unicode.cxx
index 2db8575785f1..9acdd9b66d87 100644
--- a/i18npool/source/characterclassification/cclass_unicode.cxx
+++ b/i18npool/source/characterclassification/cclass_unicode.cxx
@@ -99,7 +99,7 @@ cclass_Unicode::toTitle( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount,
nCount = len - nPos;
trans->setMappingType(MappingTypeToTitle, rLocale);
- rtl_uString* pStr = x_rtl_uString_new_WithLength( nCount, 1 );
+ rtl_uString* pStr = x_rtl_uString_new_WithLength(nCount);
sal_Unicode* out = pStr->buffer;
BreakIteratorImpl brk(xMSF);
Boundary bdy = brk.getWordBoundary(Text, nPos, rLocale,
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx
index 933a2f548d4a..6d0a1d4efec6 100644
--- a/i18npool/source/nativenumber/nativenumbersupplier.cxx
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -83,7 +83,8 @@ OUString SAL_CALL AsciiToNativeChar( const OUString& inStr, sal_Int32 startPos,
if (useOffset)
offset.realloc(nCount);
- for (sal_Int32 i = 0; i < nCount; i++) {
+ for (sal_Int32 i = 0; i < nCount; i++)
+ {
sal_Unicode ch = src[i];
if (isNumber(ch))
newStr->buffer[i] = NumberChar[number][ ch - NUMBER_ZERO ];
@@ -99,7 +100,7 @@ OUString SAL_CALL AsciiToNativeChar( const OUString& inStr, sal_Int32 startPos,
if (useOffset)
offset[i] = startPos + i;
}
- return OUString(newStr->buffer, nCount);
+ return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
}
sal_Bool SAL_CALL AsciiToNative_numberMaker(const sal_Unicode *str, sal_Int32 begin, sal_Int32 len,
diff --git a/i18npool/source/textconversion/textconversion_zh.cxx b/i18npool/source/textconversion/textconversion_zh.cxx
index b9460eb44119..507f10221e33 100644
--- a/i18npool/source/textconversion/textconversion_zh.cxx
+++ b/i18npool/source/textconversion/textconversion_zh.cxx
@@ -86,11 +86,11 @@ TextConversion_zh::getCharConversion(const OUString& aText, sal_Int32 nStartPos,
Index = ((const sal_uInt16* (*)())getFunctionBySymbol("getSTC_CharIndex_S2T"))();
}
- rtl_uString * newStr = x_rtl_uString_new_WithLength( nLength ); // defined in x_rtl_ustring.h
+ rtl_uString * newStr = x_rtl_uString_new_WithLength(nLength);
for (sal_Int32 i = 0; i < nLength; i++)
newStr->buffer[i] =
getOneCharConversion(aText[nStartPos+i], Data, Index);
- return OUString( newStr->buffer, nLength);
+ return OUString(newStr, SAL_NO_ACQUIRE); //take ownership
}
OUString SAL_CALL
diff --git a/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx b/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx
index 4ecfbf00be9f..15395d4a0b7b 100644
--- a/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx
@@ -87,8 +87,8 @@ ignoreIandEfollowedByYa_ja_JP::folding( const OUString& inStr, sal_Int32 startPo
throw(RuntimeException)
{
// Create a string buffer which can hold nCount + 1 characters.
- // The reference count is 0 now.
- rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h
+ // The reference count is 1 now.
+ rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
sal_Unicode * dst = newStr->buffer;
const sal_Unicode * src = inStr.getStr() + startPos;
@@ -145,7 +145,7 @@ ignoreIandEfollowedByYa_ja_JP::folding( const OUString& inStr, sal_Int32 startPo
newStr->length = sal_Int32(dst - newStr->buffer);
if (useOffset)
offset.realloc(newStr->length);
- return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1.
+ return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx b/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx
index 59872eb78995..cc79da1dc528 100644
--- a/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx
@@ -102,8 +102,8 @@ ignoreIterationMark_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, s
oneToOneMapping aTable(ignoreIterationMark_ja_JP_mappingTable, sizeof(ignoreIterationMark_ja_JP_mappingTable));
// Create a string buffer which can hold nCount + 1 characters.
- // The reference count is 0 now.
- rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h
+ // The reference count is 1 now.
+ rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
sal_Unicode * dst = newStr->buffer;
const sal_Unicode * src = inStr.getStr() + startPos;
@@ -152,7 +152,7 @@ ignoreIterationMark_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, s
newStr->length = sal_Int32(dst - newStr->buffer);
if (useOffset)
offset.realloc(newStr->length);
- return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1.
+ return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
}
diff --git a/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx b/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx
index f8d5cfd07b54..57abcff573aa 100644
--- a/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx
@@ -47,8 +47,8 @@ ignoreKiKuFollowedBySa_ja_JP::folding( const OUString& inStr, sal_Int32 startPos
throw(RuntimeException)
{
// Create a string buffer which can hold nCount + 1 characters.
- // The reference count is 0 now.
- rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h
+ // The reference count is 1 now.
+ rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
sal_Unicode * dst = newStr->buffer;
const sal_Unicode * src = inStr.getStr() + startPos;
@@ -102,7 +102,7 @@ ignoreKiKuFollowedBySa_ja_JP::folding( const OUString& inStr, sal_Int32 startPos
newStr->length = sal_Int32(dst - newStr->buffer);
if (useOffset)
offset.realloc(newStr->length);
- return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1.
+ return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx b/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx
index 9689b6b8e0fb..fd309ec6527b 100644
--- a/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx
@@ -309,8 +309,8 @@ ignoreProlongedSoundMark_ja_JP::folding( const OUString& inStr, sal_Int32 startP
throw(RuntimeException)
{
// Create a string buffer which can hold nCount + 1 characters.
- // The reference count is 0 now.
- rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h
+ // The reference count is 1 now.
+ rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
sal_Unicode * dst = newStr->buffer;
const sal_Unicode * src = inStr.getStr() + startPos;
@@ -360,7 +360,7 @@ ignoreProlongedSoundMark_ja_JP::folding( const OUString& inStr, sal_Int32 startP
newStr->length = sal_Int32(dst - newStr->buffer);
if (useOffset)
offset.realloc(newStr->length);
- return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1.
+ return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
}
diff --git a/i18npool/source/transliteration/transliteration_Ignore.cxx b/i18npool/source/transliteration/transliteration_Ignore.cxx
index 4c68197b5d87..3d812722df65 100644
--- a/i18npool/source/transliteration/transliteration_Ignore.cxx
+++ b/i18npool/source/transliteration/transliteration_Ignore.cxx
@@ -137,8 +137,8 @@ transliteration_Ignore::folding( const OUString& inStr, sal_Int32 startPos,
throw(RuntimeException)
{
// Create a string buffer which can hold nCount + 1 characters.
- // The reference count is 0 now.
- rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h
+ // The reference count is 1 now.
+ rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
sal_Unicode * dst = newStr->buffer;
const sal_Unicode * src = inStr.getStr() + startPos;
@@ -209,7 +209,7 @@ transliteration_Ignore::folding( const OUString& inStr, sal_Int32 startPos,
offset.realloc(newStr->length);
*dst = (sal_Unicode) 0;
- return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1.
+ return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
}
sal_Unicode SAL_CALL
diff --git a/i18npool/source/transliteration/transliteration_Numeric.cxx b/i18npool/source/transliteration/transliteration_Numeric.cxx
index 5a1de0351a9c..f2250fb0b4e4 100644
--- a/i18npool/source/transliteration/transliteration_Numeric.cxx
+++ b/i18npool/source/transliteration/transliteration_Numeric.cxx
@@ -78,7 +78,7 @@ transliteration_Numeric::transliterateBullet( const OUString& inStr, sal_Int32 s
if (endPos > inStr.getLength())
endPos = inStr.getLength();
- rtl_uString* pStr = x_rtl_uString_new_WithLength( nCount, 1 ); // our x_rtl_ustring.h
+ rtl_uString* pStr = x_rtl_uString_new_WithLength(nCount);
sal_Unicode* out = pStr->buffer;
if (useOffset)
diff --git a/i18npool/source/transliteration/transliteration_OneToOne.cxx b/i18npool/source/transliteration/transliteration_OneToOne.cxx
index f22e57a8e219..26f0732d514c 100644
--- a/i18npool/source/transliteration/transliteration_OneToOne.cxx
+++ b/i18npool/source/transliteration/transliteration_OneToOne.cxx
@@ -74,8 +74,8 @@ transliteration_OneToOne::transliterate( const OUString& inStr, sal_Int32 startP
throw(RuntimeException)
{
// Create a string buffer which can hold nCount + 1 characters.
- // The reference count is 0 now.
- rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h
+ // The reference count is 1 now.
+ rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
sal_Unicode * dst = newStr->buffer;
const sal_Unicode * src = inStr.getStr() + startPos;
@@ -97,7 +97,7 @@ transliteration_OneToOne::transliterate( const OUString& inStr, sal_Int32 startP
}
*dst = (sal_Unicode) 0;
- return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1.
+ return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
}
sal_Unicode SAL_CALL
diff --git a/i18npool/source/transliteration/transliteration_body.cxx b/i18npool/source/transliteration/transliteration_body.cxx
index 84ae11349a32..294f0a1f89a9 100644
--- a/i18npool/source/transliteration/transliteration_body.cxx
+++ b/i18npool/source/transliteration/transliteration_body.cxx
@@ -129,7 +129,7 @@ Transliteration_body::transliterate(
const Mapping &map = casefolding::getValue( in, i, nCount, aLocale, nTmpMappingType );
nOffCount += map.nmap;
}
- rtl_uString* pStr = x_rtl_uString_new_WithLength( nOffCount, 1 ); // our x_rtl_ustring.h
+ rtl_uString* pStr = x_rtl_uString_new_WithLength(nOffCount);
sal_Unicode* out = pStr->buffer;
if ( nOffCount != offset.getLength() )
@@ -199,7 +199,7 @@ OUString SAL_CALL
Transliteration_body::transliterateChar2String( sal_Unicode inChar ) throw(RuntimeException)
{
const Mapping &map = casefolding::getValue(&inChar, 0, 1, aLocale, nMappingType);
- rtl_uString* pStr = x_rtl_uString_new_WithLength( map.nmap, 1 ); // our x_rtl_ustring.h
+ rtl_uString* pStr = x_rtl_uString_new_WithLength(map.nmap);
sal_Unicode* out = pStr->buffer;
sal_Int32 i;
diff --git a/i18nutil/inc/i18nutil/x_rtl_ustring.h b/i18nutil/inc/i18nutil/x_rtl_ustring.h
index 848cc9e5eb6e..406817a9e7d4 100644
--- a/i18nutil/inc/i18nutil/x_rtl_ustring.h
+++ b/i18nutil/inc/i18nutil/x_rtl_ustring.h
@@ -38,19 +38,25 @@
* Allocates a new <code>rtl_uString</code> with capacity of nLen + 1
* characters.
*
- * The reference count is 0. The characters of the capacity are not cleared,
+ * The reference count is 1. The characters of the capacity are not cleared,
* unlike the similar method of rtl_uString_new_WithLength in rtl/ustring.h, so
- * is more efficient for allocating a new string. You need to "acquire" by such
- * as OUString( rtl_uString * value ) if you intend to use it for a while.
+ * is more efficient for allocating a new string.
+ *
+ * call rtl_uString_release to release the string
+ * alternatively pass ownership to an OUString with
+ * rtl::OUString(newStr, SAL_NO_ACQUIRE);
+ *
* @param nLen
* @return newStr
*/
-I18NUTIL_DLLPUBLIC inline rtl_uString * SAL_CALL x_rtl_uString_new_WithLength( sal_Int32 nLen, sal_Int32 _refCount = 0 )
+I18NUTIL_DLLPUBLIC inline rtl_uString * SAL_CALL x_rtl_uString_new_WithLength( sal_Int32 nLen )
{
- rtl_uString *newStr = (rtl_uString*) rtl_allocateMemory ( sizeof(rtl_uString) + sizeof(sal_Unicode) * nLen);
- newStr->refCount = _refCount;
- newStr->length = nLen;
- return newStr;
+ //rtl_uString contains sal_Unicode buffer[1], so an input of nLen allocates
+ //a buffer of nLen + 1
+ rtl_uString *newStr = (rtl_uString*) rtl_allocateMemory ( sizeof(rtl_uString) + sizeof(sal_Unicode) * nLen);
+ newStr->refCount = 1;
+ newStr->length = nLen;
+ return newStr;
}
/**
diff --git a/i18nutil/source/utility/widthfolding.cxx b/i18nutil/source/utility/widthfolding.cxx
index ed636b2e5cc4..edfe573e70be 100644
--- a/i18nutil/source/utility/widthfolding.cxx
+++ b/i18nutil/source/utility/widthfolding.cxx
@@ -55,7 +55,8 @@ OUString widthfolding::decompose_ja_voiced_sound_marks (const OUString& inStr, s
{
// Create a string buffer which can hold nCount * 2 + 1 characters.
// Its size may become double of nCount.
- rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount * 2 ); // defined in x_rtl_ustring.h The reference count is 0 now.
+ // The reference count is 1 now.
+ rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount * 2);
sal_Int32 *p = NULL;
sal_Int32 position = 0;
@@ -99,7 +100,7 @@ OUString widthfolding::decompose_ja_voiced_sound_marks (const OUString& inStr, s
newStr->length = sal_Int32(dst - newStr->buffer);
if (useOffset)
offset.realloc(newStr->length);
- return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1.
+ return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
}
oneToOneMapping& widthfolding::getfull2halfTable(void)
@@ -116,8 +117,8 @@ OUString widthfolding::compose_ja_voiced_sound_marks (const OUString& inStr, sal
{
// Create a string buffer which can hold nCount + 1 characters.
// Its size may become equal to nCount or smaller.
- // The reference count is 0 now.
- rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h
+ // The reference count is 1 now.
+ rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
// Prepare pointers of unicode character arrays.
const sal_Unicode* src = inStr.getStr() + startPos;
@@ -204,7 +205,7 @@ OUString widthfolding::compose_ja_voiced_sound_marks (const OUString& inStr, sal
}
if (useOffset)
offset.realloc(newStr->length);
- return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1.
+ return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
}
oneToOneMapping& widthfolding::gethalf2fullTable(void)