зеркало из https://github.com/mozilla/pjs.git
freed gUpperMap and gLowerMap in nsCaseConversionImp2
This commit is contained in:
Родитель
ce1be74e8b
Коммит
e57b4c9e7e
|
@ -135,19 +135,13 @@ PRUnichar nsCompressedMap::Lookup(
|
||||||
|
|
||||||
NS_DEFINE_IID(kCaseConversionIID, NS_ICASECONVERSION_IID);
|
NS_DEFINE_IID(kCaseConversionIID, NS_ICASECONVERSION_IID);
|
||||||
|
|
||||||
PRBool nsCaseConversionImp2::gInit = PR_FALSE;
|
nsrefcnt nsCaseConversionImp2::gInit = 0;
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(nsCaseConversionImp2, kCaseConversionIID);
|
NS_IMPL_ISUPPORTS(nsCaseConversionImp2, kCaseConversionIID);
|
||||||
|
|
||||||
static nsCompressedMap *gUpperMap = nsnull;
|
static nsCompressedMap *gUpperMap = nsnull;
|
||||||
static nsCompressedMap *gLowerMap = nsnull;
|
static nsCompressedMap *gLowerMap = nsnull;
|
||||||
|
|
||||||
void nsCaseConversionImp2::Init()
|
|
||||||
{
|
|
||||||
gUpperMap = new nsCompressedMap(&gToUpper[0], gToUpperItems);
|
|
||||||
gLowerMap = new nsCompressedMap(&gToLower[0], gToLowerItems);
|
|
||||||
gInit = PR_TRUE;
|
|
||||||
}
|
|
||||||
nsresult nsCaseConversionImp2::ToUpper(
|
nsresult nsCaseConversionImp2::ToUpper(
|
||||||
PRUnichar aChar, PRUnichar* aReturn
|
PRUnichar aChar, PRUnichar* aReturn
|
||||||
)
|
)
|
||||||
|
@ -320,13 +314,21 @@ nsresult nsCaseConversionImp2::ToTitle(
|
||||||
|
|
||||||
nsCaseConversionImp2::nsCaseConversionImp2()
|
nsCaseConversionImp2::nsCaseConversionImp2()
|
||||||
{
|
{
|
||||||
if(! gInit)
|
if (gInit++ == 0) {
|
||||||
Init();
|
gUpperMap = new nsCompressedMap(&gToUpper[0], gToUpperItems);
|
||||||
NS_INIT_REFCNT();
|
gLowerMap = new nsCompressedMap(&gToLower[0], gToLowerItems);
|
||||||
PR_AtomicIncrement(&g_InstanceCount);
|
}
|
||||||
|
NS_INIT_REFCNT();
|
||||||
|
PR_AtomicIncrement(&g_InstanceCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCaseConversionImp2::~nsCaseConversionImp2()
|
nsCaseConversionImp2::~nsCaseConversionImp2()
|
||||||
{
|
{
|
||||||
PR_AtomicDecrement(&g_InstanceCount);
|
PR_AtomicDecrement(&g_InstanceCount);
|
||||||
|
if (--gInit == 0) {
|
||||||
|
delete gUpperMap;
|
||||||
|
gUpperMap = nsnull;
|
||||||
|
delete gLowerMap;
|
||||||
|
gLowerMap = nsnull;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,8 @@ public:
|
||||||
NS_IMETHOD ToTitle(const PRUnichar* anArray, PRUnichar* aReturn,
|
NS_IMETHOD ToTitle(const PRUnichar* anArray, PRUnichar* aReturn,
|
||||||
PRUint32 aLen, PRBool aStartInWordBoundary = PR_TRUE);
|
PRUint32 aLen, PRBool aStartInWordBoundary = PR_TRUE);
|
||||||
|
|
||||||
void Init();
|
|
||||||
private:
|
private:
|
||||||
static PRBool gInit;
|
static nsrefcnt gInit;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче