diff --git a/mozilla/caps/include/nsPrincipalArray.h b/mozilla/caps/include/nsPrincipalArray.h index 4404f4f15e1..e0d7959fce5 100644 --- a/mozilla/caps/include/nsPrincipalArray.h +++ b/mozilla/caps/include/nsPrincipalArray.h @@ -32,6 +32,10 @@ NS_DECL_ISUPPORTS nsPrincipalArray(void); nsPrincipalArray(PRUint32 count); + +void +Init(PRUint32 count); + virtual ~nsPrincipalArray(); NS_IMETHOD diff --git a/mozilla/caps/src/nsCCapsManager.cpp b/mozilla/caps/src/nsCCapsManager.cpp index dce90a5abf5..cb4e5b7b038 100644 --- a/mozilla/caps/src/nsCCapsManager.cpp +++ b/mozilla/caps/src/nsCCapsManager.cpp @@ -78,7 +78,6 @@ nsCCapsManager::GetPermission(nsIPrincipal * prin, nsITarget * ignoreTarget, PRI { * privilegeState = nsIPrivilege::PrivilegeState_Blank; nsITarget * target = nsTarget::FindTarget(ALL_JAVA_PERMISSION); - nsresult result = NS_OK; if( target == NULL ) return NS_OK; if (nsPrivilegeManager::GetPrivilegeManager() != NULL) { nsIPrivilege * privilege; diff --git a/mozilla/caps/src/nsCaps.cpp b/mozilla/caps/src/nsCaps.cpp index d8a0552b51f..c347b59dede 100644 --- a/mozilla/caps/src/nsCaps.cpp +++ b/mozilla/caps/src/nsCaps.cpp @@ -43,8 +43,6 @@ PRBool registrationModeFlag = PR_FALSE; PR_BEGIN_EXTERN_C -static PRBool bNSCapsInitialized_g = PR_FALSE; - /* * C API FOR JS * diff --git a/mozilla/caps/src/nsPrincipalArray.cpp b/mozilla/caps/src/nsPrincipalArray.cpp index 13fefd80362..aba8854aaea 100644 --- a/mozilla/caps/src/nsPrincipalArray.cpp +++ b/mozilla/caps/src/nsPrincipalArray.cpp @@ -23,14 +23,22 @@ static NS_DEFINE_IID(kIPrincipalArrayIID, NS_IPRINCIPALARRAY_IID); NS_IMPL_ISUPPORTS(nsPrincipalArray, kIPrincipalArrayIID); nsPrincipalArray::nsPrincipalArray(void) { - nsPrincipalArray(0); + this->Init(0); } nsPrincipalArray::nsPrincipalArray(PRUint32 count) { - itsArray = new nsVector(); - if(itsArray) - itsArray->SetSize(count, 1); + this->Init(count); +} + +void +nsPrincipalArray::Init(PRUint32 count) +{ + NS_INIT_REFCNT(); + NS_ADDREF(this); + this->itsArray = new nsVector(); + if(this->itsArray) + this->itsArray->SetSize(count, 1); } nsPrincipalArray::~nsPrincipalArray(void) { @@ -38,25 +46,25 @@ nsPrincipalArray::~nsPrincipalArray(void) } NS_IMETHODIMP -nsPrincipalArray::SetPrincipalArrayElement(PRUint32 index, nsIPrincipal * principal) +nsPrincipalArray::SetPrincipalArrayElement(PRUint32 itsIndex, nsIPrincipal * principal) { - if (itsArray != NULL) this->itsArray->Set(index, principal); + if (this->itsArray != NULL) this->itsArray->Set(itsIndex, principal); return NS_OK; } NS_IMETHODIMP nsPrincipalArray::GetPrincipalArraySize(PRUint32 * size) { - * size = (itsArray == NULL) ? 0 : itsArray->GetSize(); + * size = (this->itsArray == NULL) ? 0 : this->itsArray->GetSize(); return NS_OK; } NS_IMETHODIMP nsPrincipalArray::FreePrincipalArray() { - if (itsArray) { - itsArray->RemoveAll(); - delete itsArray; + if (this->itsArray) { + this->itsArray->RemoveAll(); + delete this->itsArray; } return NS_OK; } @@ -64,15 +72,15 @@ nsPrincipalArray::FreePrincipalArray() NS_IMETHODIMP nsPrincipalArray::AddPrincipalArrayElement(nsIPrincipal * principal) { - if(!itsArray) itsArray = new nsVector(); + if(!this->itsArray) this->itsArray = new nsVector(); itsArray->Add(principal); return NS_OK; } NS_IMETHODIMP -nsPrincipalArray::GetPrincipalArrayElement(PRUint32 index, nsIPrincipal * * result) +nsPrincipalArray::GetPrincipalArrayElement(PRUint32 itsIndex, nsIPrincipal * * result) { - * result = (itsArray == NULL) ? NULL : (nsIPrincipal *) itsArray->Get(index); + * result = (this->itsArray) ? (nsIPrincipal *) this->itsArray->Get(itsIndex) : NULL; return NS_OK; } @@ -99,7 +107,7 @@ nsPrincipalArray::ComparePrincipalArray(nsIPrincipalArray * other, PRInt16 * com * comparisonType = nsPrincipalArray::SetComparisonType_NoSubset; return NS_OK; } - if (value == PR_TRUE) p2Hashtable->Put(&prinKey, (void *)PR_FALSE); + if (value == PR_TRUE) p2Hashtable->Put(& prinKey, (void *)PR_FALSE); } other->GetPrincipalArraySize(& i); while(i-- > 0) { diff --git a/mozilla/caps/src/nsPrincipalManager.cpp b/mozilla/caps/src/nsPrincipalManager.cpp index d7d7dd95df3..4a3653da611 100644 --- a/mozilla/caps/src/nsPrincipalManager.cpp +++ b/mozilla/caps/src/nsPrincipalManager.cpp @@ -72,7 +72,7 @@ nsPrincipalManager::HasSystemPrincipal(nsIPrincipalArray * prinArray) if (sysPrin == NULL) return PR_FALSE; PRUint32 i; prinArray->GetPrincipalArraySize(& i); - for (i; i-- > 0;) { + while(i-- > 0) { prinArray->GetPrincipalArrayElement(i,& prin); PRBool result; sysPrin->Equals(prin, & result);