diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-08-31 23:00:49 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-09-01 09:53:36 +0100 |
commit | 23854ea235ef32232f34c6ff121f005310f8c01b (patch) | |
tree | 82d2ba080d849cc5cdd801c0d98fc1ccd014ea39 /i18npool | |
parent | 5e51cc84d9a9885cc081dd409697244dcd7a67c8 (diff) |
refactor x_rtl_uString_new_WithLength to be consistent
i.e. change x_rtl_uString_new_WithLength to always create a rtl_uString
with ref count of 1, like rtl_uString_new_WithLength, so requiring:
either the explicit use of rtl_uString_release or
passing ownership to an OUString via OUString(pStr, SAL_NO_ACQUIRE)
which will do the same in its dtor
Diffstat (limited to 'i18npool')
11 files changed, 27 insertions, 26 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; |