mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1221550 - use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in intl/; r=smontagu
This commit is contained in:
parent
b38c258df0
commit
c7a99efd2c
@ -17,6 +17,7 @@
|
||||
#include "prprf.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
@ -268,11 +269,11 @@ nsLocaleService::GetLocaleFromAcceptLanguage(const char *acceptLanguage, nsILoca
|
||||
char acceptLanguageList[NSILOCALE_MAX_ACCEPT_LANGUAGE][NSILOCALE_MAX_ACCEPT_LENGTH];
|
||||
nsresult result;
|
||||
|
||||
nsAutoArrayPtr<char> input(new char[strlen(acceptLanguage)+1]);
|
||||
auto input = MakeUnique<char[]>(strlen(acceptLanguage)+1);
|
||||
|
||||
strcpy(input, acceptLanguage);
|
||||
cPtr1 = input-1;
|
||||
cPtr2 = input;
|
||||
strcpy(input.get(), acceptLanguage);
|
||||
cPtr1 = input.get()-1;
|
||||
cPtr2 = input.get();
|
||||
|
||||
/* put in standard form */
|
||||
while (*(++cPtr1)) {
|
||||
@ -286,7 +287,7 @@ nsLocaleService::GetLocaleFromAcceptLanguage(const char *acceptLanguage, nsILoca
|
||||
|
||||
countLang = 0;
|
||||
|
||||
if (strchr(input,';')) {
|
||||
if (strchr(input.get(), ';')) {
|
||||
/* deal with the quality values */
|
||||
|
||||
float qvalue[NSILOCALE_MAX_ACCEPT_LANGUAGE];
|
||||
@ -295,7 +296,7 @@ nsLocaleService::GetLocaleFromAcceptLanguage(const char *acceptLanguage, nsILoca
|
||||
char* ptrLanguage[NSILOCALE_MAX_ACCEPT_LANGUAGE];
|
||||
char* ptrSwap;
|
||||
|
||||
cPtr = nsCRT::strtok(input,",",&cPtr2);
|
||||
cPtr = nsCRT::strtok(input.get(),",",&cPtr2);
|
||||
while (cPtr) {
|
||||
qvalue[countLang] = 1.0f;
|
||||
/* add extra parens to get rid of warning */
|
||||
@ -332,7 +333,7 @@ nsLocaleService::GetLocaleFromAcceptLanguage(const char *acceptLanguage, nsILoca
|
||||
} else {
|
||||
/* simple case: no quality values */
|
||||
|
||||
cPtr = nsCRT::strtok(input,",",&cPtr2);
|
||||
cPtr = nsCRT::strtok(input.get(),",",&cPtr2);
|
||||
while (cPtr) {
|
||||
if (strlen(cPtr)<NSILOCALE_MAX_ACCEPT_LENGTH) { /* ignore if too long */
|
||||
PL_strncpyz(acceptLanguageList[countLang++],cPtr,NSILOCALE_MAX_ACCEPT_LENGTH);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
using mozilla::dom::EncodingUtils;
|
||||
|
||||
@ -40,13 +41,12 @@ ToUTF8(const nsACString &aString, const char *aCharset,
|
||||
rv = unicodeDecoder->GetMaxLength(inStr.get(), srcLen, &dstLen);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoArrayPtr<char16_t> ustr(new char16_t[dstLen]);
|
||||
auto ustr = mozilla::MakeUnique<char16_t[]>(dstLen);
|
||||
NS_ENSURE_TRUE(ustr, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = unicodeDecoder->Convert(inStr.get(), &srcLen, ustr, &dstLen);
|
||||
rv = unicodeDecoder->Convert(inStr.get(), &srcLen, ustr.get(), &dstLen);
|
||||
if (NS_SUCCEEDED(rv)){
|
||||
// Tru64 Cxx needs an explicit get()
|
||||
CopyUTF16toUTF8(Substring(ustr.get(), ustr + dstLen), aResult);
|
||||
CopyUTF16toUTF8(Substring(ustr.get(), ustr.get() + dstLen), aResult);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "unicpriv.h"
|
||||
#include "nsUnicodeDecodeHelper.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsUnicodeDecodeHelper [implementation]
|
||||
@ -224,11 +224,11 @@ nsresult nsUnicodeDecodeHelper::CreateFastTable(
|
||||
{
|
||||
int32_t tableSize = aTableSize;
|
||||
int32_t buffSize = aTableSize;
|
||||
nsAutoArrayPtr<char> buff(new char [buffSize]);
|
||||
auto buff = mozilla::MakeUnique<char[]>(buffSize);
|
||||
|
||||
char * p = buff;
|
||||
char * p = buff.get();
|
||||
for (int32_t i=0; i<aTableSize; i++) *(p++) = i;
|
||||
return ConvertByTable(buff, &buffSize, aFastTable, &tableSize,
|
||||
return ConvertByTable(buff.get(), &buffSize, aFastTable, &tableSize,
|
||||
u1ByteCharset, nullptr, aMappingTable);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user