Changed some code to use XPCOM ref counting related macros

This commit is contained in:
troy%netscape.com 1998-10-05 05:11:18 +00:00
parent 889df957d3
commit fa70c38667
25 changed files with 70 additions and 74 deletions

View File

@ -2490,7 +2490,8 @@ NS_HTML nsresult
return NS_ERROR_NULL_POINTER;
}
CSSDeclarationImpl *it = new CSSDeclarationImpl();
CSSDeclarationImpl *it;
NS_NEWXPCOM(it, CSSDeclarationImpl);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -321,7 +321,7 @@ CSSParserImpl::CSSParserImpl(nsICSSStyleSheet* aSheet)
{
NS_INIT_REFCNT();
mScanner = nsnull;
mSheet = aSheet; aSheet->AddRef();
mSheet = aSheet; NS_ADDREF(aSheet);
mHavePushBack = PR_FALSE;
}
@ -375,9 +375,7 @@ CSSParserImpl::Parse(nsIUnicharInputStream* aInput,
mScanner = new nsCSSScanner();
mScanner->Init(aInput);
mURL = aInputURL;
if (nsnull != aInputURL) {
aInputURL->AddRef();
}
NS_IF_ADDREF(aInputURL);
mInHead = PR_TRUE;
nsCSSToken* tk = &mToken;
for (;;) {
@ -443,6 +441,7 @@ CSSParserImpl::ParseDeclarations(const nsString& aDeclaration,
rule->SetDeclaration(declaration);
rule->SetWeight(0x7fffffff);
aResult = rule;
NS_RELEASE(declaration);
}
else {
aResult = nsnull;

View File

@ -109,9 +109,7 @@ void nsCSSScanner::Init(nsIUnicharInputStream* aInput)
NS_PRECONDITION(nsnull != aInput, kNullPointer);
Close();
mInput = aInput;
if (nsnull != aInput) {
aInput->AddRef();
}
NS_IF_ADDREF(aInput);
}
void nsCSSScanner::Close()

View File

@ -2490,7 +2490,8 @@ NS_HTML nsresult
return NS_ERROR_NULL_POINTER;
}
CSSDeclarationImpl *it = new CSSDeclarationImpl();
CSSDeclarationImpl *it;
NS_NEWXPCOM(it, CSSDeclarationImpl);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -372,7 +372,7 @@ nsrefcnt CSSStyleRuleImpl::Release(void)
fprintf(stdout, "%d Release CSSStyleRule\n", mRefCnt - 1);
}
if (--mRefCnt == 0) {
delete this;
NS_DELETEXPCOM(this);
return 0;
}
return mRefCnt;
@ -392,17 +392,17 @@ nsresult CSSStyleRuleImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kICSSStyleRuleIID)) {
*aInstancePtrResult = (void*) ((nsICSSStyleRule*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleRuleIID)) {
*aInstancePtrResult = (void*) ((nsIStyleRule*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;

View File

@ -382,17 +382,17 @@ nsresult CSSStyleSheetImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kICSSStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsICSSStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;

View File

@ -375,17 +375,17 @@ nsresult HTMLAttributesImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kIHTMLAttributesIID)) {
*aInstancePtrResult = (void*) ((nsIHTMLAttributes*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleRuleIID)) {
*aInstancePtrResult = (void*) ((nsIStyleRule*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)(nsIHTMLAttributes*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;

View File

@ -218,17 +218,17 @@ nsresult HTMLCSSStyleSheetImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kIHTMLCSSStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIHTMLCSSStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;

View File

@ -406,22 +406,22 @@ nsresult HTMLStyleSheetImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kIHTMLStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIHTMLStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleFrameConstructionIID)) {
*aInstancePtrResult = (void*) ((nsIStyleFrameConstruction*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) this;
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;

View File

@ -2490,7 +2490,8 @@ NS_HTML nsresult
return NS_ERROR_NULL_POINTER;
}
CSSDeclarationImpl *it = new CSSDeclarationImpl();
CSSDeclarationImpl *it;
NS_NEWXPCOM(it, CSSDeclarationImpl);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -321,7 +321,7 @@ CSSParserImpl::CSSParserImpl(nsICSSStyleSheet* aSheet)
{
NS_INIT_REFCNT();
mScanner = nsnull;
mSheet = aSheet; aSheet->AddRef();
mSheet = aSheet; NS_ADDREF(aSheet);
mHavePushBack = PR_FALSE;
}
@ -375,9 +375,7 @@ CSSParserImpl::Parse(nsIUnicharInputStream* aInput,
mScanner = new nsCSSScanner();
mScanner->Init(aInput);
mURL = aInputURL;
if (nsnull != aInputURL) {
aInputURL->AddRef();
}
NS_IF_ADDREF(aInputURL);
mInHead = PR_TRUE;
nsCSSToken* tk = &mToken;
for (;;) {
@ -443,6 +441,7 @@ CSSParserImpl::ParseDeclarations(const nsString& aDeclaration,
rule->SetDeclaration(declaration);
rule->SetWeight(0x7fffffff);
aResult = rule;
NS_RELEASE(declaration);
}
else {
aResult = nsnull;

View File

@ -109,9 +109,7 @@ void nsCSSScanner::Init(nsIUnicharInputStream* aInput)
NS_PRECONDITION(nsnull != aInput, kNullPointer);
Close();
mInput = aInput;
if (nsnull != aInput) {
aInput->AddRef();
}
NS_IF_ADDREF(aInput);
}
void nsCSSScanner::Close()

View File

@ -372,7 +372,7 @@ nsrefcnt CSSStyleRuleImpl::Release(void)
fprintf(stdout, "%d Release CSSStyleRule\n", mRefCnt - 1);
}
if (--mRefCnt == 0) {
delete this;
NS_DELETEXPCOM(this);
return 0;
}
return mRefCnt;
@ -392,17 +392,17 @@ nsresult CSSStyleRuleImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kICSSStyleRuleIID)) {
*aInstancePtrResult = (void*) ((nsICSSStyleRule*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleRuleIID)) {
*aInstancePtrResult = (void*) ((nsIStyleRule*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;

View File

@ -382,17 +382,17 @@ nsresult CSSStyleSheetImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kICSSStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsICSSStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;

View File

@ -375,17 +375,17 @@ nsresult HTMLAttributesImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kIHTMLAttributesIID)) {
*aInstancePtrResult = (void*) ((nsIHTMLAttributes*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleRuleIID)) {
*aInstancePtrResult = (void*) ((nsIStyleRule*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)(nsIHTMLAttributes*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;

View File

@ -218,17 +218,17 @@ nsresult HTMLCSSStyleSheetImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kIHTMLCSSStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIHTMLCSSStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;

View File

@ -406,22 +406,22 @@ nsresult HTMLStyleSheetImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kIHTMLStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIHTMLStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleFrameConstructionIID)) {
*aInstancePtrResult = (void*) ((nsIStyleFrameConstruction*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) this;
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;

View File

@ -2490,7 +2490,8 @@ NS_HTML nsresult
return NS_ERROR_NULL_POINTER;
}
CSSDeclarationImpl *it = new CSSDeclarationImpl();
CSSDeclarationImpl *it;
NS_NEWXPCOM(it, CSSDeclarationImpl);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -321,7 +321,7 @@ CSSParserImpl::CSSParserImpl(nsICSSStyleSheet* aSheet)
{
NS_INIT_REFCNT();
mScanner = nsnull;
mSheet = aSheet; aSheet->AddRef();
mSheet = aSheet; NS_ADDREF(aSheet);
mHavePushBack = PR_FALSE;
}
@ -375,9 +375,7 @@ CSSParserImpl::Parse(nsIUnicharInputStream* aInput,
mScanner = new nsCSSScanner();
mScanner->Init(aInput);
mURL = aInputURL;
if (nsnull != aInputURL) {
aInputURL->AddRef();
}
NS_IF_ADDREF(aInputURL);
mInHead = PR_TRUE;
nsCSSToken* tk = &mToken;
for (;;) {
@ -443,6 +441,7 @@ CSSParserImpl::ParseDeclarations(const nsString& aDeclaration,
rule->SetDeclaration(declaration);
rule->SetWeight(0x7fffffff);
aResult = rule;
NS_RELEASE(declaration);
}
else {
aResult = nsnull;

View File

@ -109,9 +109,7 @@ void nsCSSScanner::Init(nsIUnicharInputStream* aInput)
NS_PRECONDITION(nsnull != aInput, kNullPointer);
Close();
mInput = aInput;
if (nsnull != aInput) {
aInput->AddRef();
}
NS_IF_ADDREF(aInput);
}
void nsCSSScanner::Close()

View File

@ -2490,7 +2490,8 @@ NS_HTML nsresult
return NS_ERROR_NULL_POINTER;
}
CSSDeclarationImpl *it = new CSSDeclarationImpl();
CSSDeclarationImpl *it;
NS_NEWXPCOM(it, CSSDeclarationImpl);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -372,7 +372,7 @@ nsrefcnt CSSStyleRuleImpl::Release(void)
fprintf(stdout, "%d Release CSSStyleRule\n", mRefCnt - 1);
}
if (--mRefCnt == 0) {
delete this;
NS_DELETEXPCOM(this);
return 0;
}
return mRefCnt;
@ -392,17 +392,17 @@ nsresult CSSStyleRuleImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kICSSStyleRuleIID)) {
*aInstancePtrResult = (void*) ((nsICSSStyleRule*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleRuleIID)) {
*aInstancePtrResult = (void*) ((nsIStyleRule*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;

View File

@ -382,17 +382,17 @@ nsresult CSSStyleSheetImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kICSSStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsICSSStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;

View File

@ -218,17 +218,17 @@ nsresult HTMLCSSStyleSheetImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kIHTMLCSSStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIHTMLCSSStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;

View File

@ -406,22 +406,22 @@ nsresult HTMLStyleSheetImpl::QueryInterface(const nsIID& aIID,
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kIHTMLStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIHTMLStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleSheetIID)) {
*aInstancePtrResult = (void*) ((nsIStyleSheet*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyleFrameConstructionIID)) {
*aInstancePtrResult = (void*) ((nsIStyleFrameConstruction*)this);
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) this;
AddRef();
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;