From 8952503f91a61ddb162ea1cb51e61561b592ff7c Mon Sep 17 00:00:00 2001 From: Saint Wesonga Date: Sun, 4 Jul 2010 21:39:17 +0200 Subject: [PATCH] Bug 562387 - Convert NS_NEWXPCOM/NS_DELETEXPCOM to new/delete. r=bsmedberg --- accessible/src/base/nsAccessNode.cpp | 2 +- caps/src/nsNullPrincipal.cpp | 2 +- caps/src/nsPrincipal.cpp | 2 +- caps/src/nsSystemPrincipal.cpp | 2 +- content/base/src/nsXMLHttpRequest.cpp | 3 +-- content/xbl/src/nsXBLContentSink.cpp | 3 +-- content/xml/document/src/nsXMLContentSink.cpp | 3 +-- dom/base/nsGlobalWindowCommands.cpp | 6 ++---- editor/composer/src/nsComposerController.cpp | 6 ++---- .../composer/src/nsComposerRegistration.cpp | 3 +-- editor/libeditor/base/nsEditorController.cpp | 6 ++---- editor/libeditor/html/nsEditorTxnLog.cpp | 2 +- embedding/browser/webBrowser/nsWebBrowser.cpp | 14 ++++++------- .../printingui/src/win/nsPrintProgress.cpp | 2 +- .../spellcheck/src/mozSpellCheckerFactory.cpp | 4 +--- gfx/src/thebes/nsThebesGfxFactory.cpp | 3 +-- gfx/thebes/gfxTypes.h | 2 +- intl/unicharutil/src/nsCaseConversionImp2.cpp | 2 +- js/src/xpconnect/src/xpcwrappedjs.cpp | 2 +- .../tests/components/xpctest_noisy.cpp | 2 +- layout/base/nsDocumentViewer.cpp | 3 +-- layout/build/nsLayoutModule.cpp | 4 +--- layout/generic/nsBulletFrame.cpp | 3 +-- layout/xul/base/src/nsImageBoxFrame.cpp | 3 +-- modules/libjar/nsJAR.cpp | 2 +- .../decoders/icon/nsIconProtocolHandler.cpp | 3 +-- modules/libpr0n/src/imgLoader.cpp | 2 +- modules/libpr0n/src/imgTools.cpp | 2 +- netwerk/base/src/nsMIMEInputStream.cpp | 3 +-- netwerk/base/src/nsStandardURL.cpp | 3 +-- netwerk/protocol/res/nsResProtocolHandler.cpp | 6 ++---- security/manager/ssl/src/nsNSSModule.cpp | 4 ++-- .../exthandler/nsExternalProtocolHandler.cpp | 3 +-- widget/src/gtk2/nsGtkIMModule.h | 2 +- widget/src/gtk2/nsWidgetFactory.cpp | 4 ++-- widget/src/os2/nsRwsService.cpp | 2 +- widget/src/qt/nsWidgetFactory.cpp | 2 +- xpcom/base/nsAgg.h | 4 ++-- xpcom/base/nsTraceRefcntImpl.cpp | 4 ++-- xpcom/glue/nsISupportsImpl.h | 10 ++++----- xpcom/glue/nsISupportsUtils.h | 21 ------------------- xpcom/io/nsInputStreamTee.cpp | 3 +-- xpcom/io/nsMultiplexInputStream.cpp | 3 +-- xpcom/proxy/src/nsProxyEventObject.cpp | 2 +- .../reflect/xptinfo/src/xptiInterfaceInfo.cpp | 2 +- xpcom/tests/TestCOMArray.cpp | 2 +- xpcom/threads/nsTimerImpl.cpp | 2 +- 47 files changed, 64 insertions(+), 111 deletions(-) diff --git a/accessible/src/base/nsAccessNode.cpp b/accessible/src/base/nsAccessNode.cpp index acf154e13e97..e78aec468271 100644 --- a/accessible/src/base/nsAccessNode.cpp +++ b/accessible/src/base/nsAccessNode.cpp @@ -131,7 +131,7 @@ void nsAccessNode::LastRelease() NS_ASSERTION(!mWeakShell, "A Shutdown() impl forgot to call its parent's Shutdown?"); } // ... then die. - NS_DELETEXPCOM(this); + delete this; } //////////////////////////////////////////////////////////////////////////////// diff --git a/caps/src/nsNullPrincipal.cpp b/caps/src/nsNullPrincipal.cpp index 1ab9155494f3..f5c11a481ff6 100644 --- a/caps/src/nsNullPrincipal.cpp +++ b/caps/src/nsNullPrincipal.cpp @@ -78,7 +78,7 @@ nsNullPrincipal::Release() nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mJSPrincipals.refcount); NS_LOG_RELEASE(this, count, "nsNullPrincipal"); if (count == 0) { - NS_DELETEXPCOM(this); + delete this; } return count; diff --git a/caps/src/nsPrincipal.cpp b/caps/src/nsPrincipal.cpp index ae2de684592a..c404a7125906 100644 --- a/caps/src/nsPrincipal.cpp +++ b/caps/src/nsPrincipal.cpp @@ -166,7 +166,7 @@ nsPrincipal::Release() nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mJSPrincipals.refcount); NS_LOG_RELEASE(this, count, "nsPrincipal"); if (count == 0) { - NS_DELETEXPCOM(this); + delete this; } return count; diff --git a/caps/src/nsSystemPrincipal.cpp b/caps/src/nsSystemPrincipal.cpp index 80764731951b..7b02804c3d26 100644 --- a/caps/src/nsSystemPrincipal.cpp +++ b/caps/src/nsSystemPrincipal.cpp @@ -75,7 +75,7 @@ nsSystemPrincipal::Release() nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mJSPrincipals.refcount); NS_LOG_RELEASE(this, count, "nsSystemPrincipal"); if (count == 0) { - NS_DELETEXPCOM(this); + delete this; } return count; diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index fc8f9db28b3d..a5e0dd5806b9 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -1360,8 +1360,7 @@ nsXMLHttpRequest::GetAllResponseHeaders(char **_retval) nsCOMPtr httpChannel = GetCurrentHttpChannel(); if (httpChannel) { - nsHeaderVisitor *visitor = nsnull; - NS_NEWXPCOM(visitor, nsHeaderVisitor); + nsHeaderVisitor *visitor = new nsHeaderVisitor(); if (!visitor) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(visitor); diff --git a/content/xbl/src/nsXBLContentSink.cpp b/content/xbl/src/nsXBLContentSink.cpp index 1168c8ff7917..31bb70abf1b9 100644 --- a/content/xbl/src/nsXBLContentSink.cpp +++ b/content/xbl/src/nsXBLContentSink.cpp @@ -71,8 +71,7 @@ NS_NewXBLContentSink(nsIXMLContentSink** aResult, { NS_ENSURE_ARG_POINTER(aResult); - nsXBLContentSink* it; - NS_NEWXPCOM(it, nsXBLContentSink); + nsXBLContentSink* it = new nsXBLContentSink(); NS_ENSURE_TRUE(it, NS_ERROR_OUT_OF_MEMORY); nsCOMPtr kungFuDeathGrip = it; diff --git a/content/xml/document/src/nsXMLContentSink.cpp b/content/xml/document/src/nsXMLContentSink.cpp index 2706ecd88a09..f3e5562f6120 100644 --- a/content/xml/document/src/nsXMLContentSink.cpp +++ b/content/xml/document/src/nsXMLContentSink.cpp @@ -124,8 +124,7 @@ NS_NewXMLContentSink(nsIXMLContentSink** aResult, if (nsnull == aResult) { return NS_ERROR_NULL_POINTER; } - nsXMLContentSink* it; - NS_NEWXPCOM(it, nsXMLContentSink); + nsXMLContentSink* it = new nsXMLContentSink(); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/dom/base/nsGlobalWindowCommands.cpp b/dom/base/nsGlobalWindowCommands.cpp index dbf2183f8ac6..f6f6c1b07389 100644 --- a/dom/base/nsGlobalWindowCommands.cpp +++ b/dom/base/nsGlobalWindowCommands.cpp @@ -909,8 +909,7 @@ nsClipboardDragDropHookCommand::GetCommandStateParams(const char *aCommandName, #define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName) \ { \ - _cmdClass* theCmd; \ - NS_NEWXPCOM(theCmd, _cmdClass); \ + _cmdClass* theCmd = new _cmdClass(); \ if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \ rv = inCommandTable->RegisterCommand(_cmdName, \ static_cast(theCmd)); \ @@ -918,8 +917,7 @@ nsClipboardDragDropHookCommand::GetCommandStateParams(const char *aCommandName, #define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \ { \ - _cmdClass* theCmd; \ - NS_NEWXPCOM(theCmd, _cmdClass); \ + _cmdClass* theCmd = new _cmdClass(); \ if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \ rv = inCommandTable->RegisterCommand(_cmdName, \ static_cast(theCmd)); diff --git a/editor/composer/src/nsComposerController.cpp b/editor/composer/src/nsComposerController.cpp index 6dea7e958124..0448972810e2 100644 --- a/editor/composer/src/nsComposerController.cpp +++ b/editor/composer/src/nsComposerController.cpp @@ -44,8 +44,7 @@ #define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName) \ { \ - _cmdClass* theCmd; \ - NS_NEWXPCOM(theCmd, _cmdClass); \ + _cmdClass* theCmd = new _cmdClass(); \ NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY); \ rv = inCommandTable->RegisterCommand(_cmdName, \ static_cast(theCmd)); \ @@ -53,8 +52,7 @@ #define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \ { \ - _cmdClass* theCmd; \ - NS_NEWXPCOM(theCmd, _cmdClass); \ + _cmdClass* theCmd = new _cmdClass(); \ NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY); \ rv = inCommandTable->RegisterCommand(_cmdName, \ static_cast(theCmd)); diff --git a/editor/composer/src/nsComposerRegistration.cpp b/editor/composer/src/nsComposerRegistration.cpp index aa823a9e420d..0ba37dbd04c7 100644 --- a/editor/composer/src/nsComposerRegistration.cpp +++ b/editor/composer/src/nsComposerRegistration.cpp @@ -84,8 +84,7 @@ nsComposeTxtSrvFilterConstructor(nsISupports *aOuter, REFNSIID aIID, { return NS_ERROR_NO_AGGREGATION; } - nsComposeTxtSrvFilter * inst; - NS_NEWXPCOM(inst, nsComposeTxtSrvFilter); + nsComposeTxtSrvFilter * inst = new nsComposeTxtSrvFilter(); if (NULL == inst) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/editor/libeditor/base/nsEditorController.cpp b/editor/libeditor/base/nsEditorController.cpp index 31dc66c8a7f8..f0c7767e7684 100644 --- a/editor/libeditor/base/nsEditorController.cpp +++ b/editor/libeditor/base/nsEditorController.cpp @@ -47,8 +47,7 @@ #define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName) \ { \ - _cmdClass* theCmd; \ - NS_NEWXPCOM(theCmd, _cmdClass); \ + _cmdClass* theCmd = new _cmdClass(); \ NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY); \ rv = inCommandTable->RegisterCommand(_cmdName, \ static_cast(theCmd)); \ @@ -56,8 +55,7 @@ #define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \ { \ - _cmdClass* theCmd; \ - NS_NEWXPCOM(theCmd, _cmdClass); \ + _cmdClass* theCmd = new _cmdClass(); \ NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY); \ rv = inCommandTable->RegisterCommand(_cmdName, \ static_cast(theCmd)); diff --git a/editor/libeditor/html/nsEditorTxnLog.cpp b/editor/libeditor/html/nsEditorTxnLog.cpp index ee78b4e20216..f44ac9f81714 100644 --- a/editor/libeditor/html/nsEditorTxnLog.cpp +++ b/editor/libeditor/html/nsEditorTxnLog.cpp @@ -70,7 +70,7 @@ nsrefcnt nsEditorTxnLog::Release(void) { NS_PRECONDITION(0 != mRefCnt, "dup release"); if (--mRefCnt == 0) { - NS_DELETEXPCOM(this); + delete this; return 0; } return mRefCnt; diff --git a/embedding/browser/webBrowser/nsWebBrowser.cpp b/embedding/browser/webBrowser/nsWebBrowser.cpp index d2bbb106d2c7..266880052454 100644 --- a/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -153,7 +153,7 @@ NS_IMETHODIMP nsWebBrowser::InternalDestroy() if (mListenerArray) { for (PRUint32 i = 0, end = mListenerArray->Length(); i < end; i++) { nsWebBrowserListenerState *state = mListenerArray->ElementAt(i); - NS_DELETEXPCOM(state); + delete state; } delete mListenerArray; mListenerArray = nsnull; @@ -237,14 +237,14 @@ NS_IMETHODIMP nsWebBrowser::AddWebBrowserListener(nsIWeakReference *aListener, c // The window hasn't been created yet, so queue up the listener. They'll be // registered when the window gets created. nsAutoPtr state; - NS_NEWXPCOM(state, nsWebBrowserListenerState); + state = new nsWebBrowserListenerState(); if (!state) return NS_ERROR_OUT_OF_MEMORY; state->mWeakPtr = aListener; state->mID = aIID; if (!mListenerArray) { - NS_NEWXPCOM(mListenerArray, nsTArray); + mListenerArray = new nsTArray(); if (!mListenerArray) { return NS_ERROR_OUT_OF_MEMORY; } @@ -315,9 +315,9 @@ NS_IMETHODIMP nsWebBrowser::RemoveWebBrowserListener(nsIWeakReference *aListener if (0 >= mListenerArray->Length()) { for (PRUint32 i = 0, end = mListenerArray->Length(); i < end; i++) { nsWebBrowserListenerState *state = mListenerArray->ElementAt(i); - NS_DELETEXPCOM(state); + delete state; } - NS_DELETEXPCOM(mListenerArray); + delete mListenerArray; mListenerArray = nsnull; } @@ -1172,9 +1172,9 @@ NS_IMETHODIMP nsWebBrowser::Create() } for (PRUint32 i = 0, end = mListenerArray->Length(); i < end; i++) { nsWebBrowserListenerState *state = mListenerArray->ElementAt(i); - NS_DELETEXPCOM(state); + delete state; } - NS_DELETEXPCOM(mListenerArray); + delete mListenerArray; mListenerArray = nsnull; } diff --git a/embedding/components/printingui/src/win/nsPrintProgress.cpp b/embedding/components/printingui/src/win/nsPrintProgress.cpp index ce030304e6ae..95ed9c7953f7 100644 --- a/embedding/components/printingui/src/win/nsPrintProgress.cpp +++ b/embedding/components/printingui/src/win/nsPrintProgress.cpp @@ -69,7 +69,7 @@ NS_IMETHODIMP_(nsrefcnt) nsPrintProgress::Release(void) mRefCnt = 1; /* stabilize */ /* enable this to find non-threadsafe destructors: */ /* NS_ASSERT_OWNINGTHREAD(nsPrintProgress); */ - NS_DELETEXPCOM(this); + delete this; return 0; } return count; diff --git a/extensions/spellcheck/src/mozSpellCheckerFactory.cpp b/extensions/spellcheck/src/mozSpellCheckerFactory.cpp index 7cf75a11dcd1..d2e159f6e382 100644 --- a/extensions/spellcheck/src/mozSpellCheckerFactory.cpp +++ b/extensions/spellcheck/src/mozSpellCheckerFactory.cpp @@ -86,15 +86,13 @@ mozInlineSpellCheckerConstructor(nsISupports *aOuter, REFNSIID aIID, nsresult rv; - mozInlineSpellChecker* inst; - *aResult = NULL; if (NULL != aOuter) { rv = NS_ERROR_NO_AGGREGATION; return rv; } - NS_NEWXPCOM(inst, mozInlineSpellChecker); + mozInlineSpellChecker* inst = new mozInlineSpellChecker(); if (NULL == inst) { rv = NS_ERROR_OUT_OF_MEMORY; return rv; diff --git a/gfx/src/thebes/nsThebesGfxFactory.cpp b/gfx/src/thebes/nsThebesGfxFactory.cpp index 51eba95aa973..cc41c55c2df6 100644 --- a/gfx/src/thebes/nsThebesGfxFactory.cpp +++ b/gfx/src/thebes/nsThebesGfxFactory.cpp @@ -74,8 +74,7 @@ nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult return rv; } - nsCOMPtr rgn; - NS_NEWXPCOM(rgn, nsThebesRegion); + nsCOMPtr rgn = new nsThebesRegion(); nsCOMPtr scriptableRgn; if (rgn != nsnull) { diff --git a/gfx/thebes/gfxTypes.h b/gfx/thebes/gfxTypes.h index 1e1f0862cb3d..cf0da2723a81 100644 --- a/gfx/thebes/gfxTypes.h +++ b/gfx/thebes/gfxTypes.h @@ -104,7 +104,7 @@ public: \ NS_LOG_RELEASE(this, count, #_class); \ if (count == 0) { \ mRefCnt = 1; /* stabilize */ \ - NS_DELETEXPCOM(this); \ + delete this; \ return 0; \ } \ return count; \ diff --git a/intl/unicharutil/src/nsCaseConversionImp2.cpp b/intl/unicharutil/src/nsCaseConversionImp2.cpp index 236ea8d5f3c5..5361909e523e 100644 --- a/intl/unicharutil/src/nsCaseConversionImp2.cpp +++ b/intl/unicharutil/src/nsCaseConversionImp2.cpp @@ -164,7 +164,7 @@ static nsCompressedMap gLowerMap = { nsCaseConversionImp2* nsCaseConversionImp2::GetInstance() { if (!gCaseConv) - NS_NEWXPCOM(gCaseConv, nsCaseConversionImp2); + gCaseConv = new nsCaseConversionImp2(); return gCaseConv; } diff --git a/js/src/xpconnect/src/xpcwrappedjs.cpp b/js/src/xpconnect/src/xpcwrappedjs.cpp index ed8c884c4b3b..87af0758be4b 100644 --- a/js/src/xpconnect/src/xpcwrappedjs.cpp +++ b/js/src/xpconnect/src/xpcwrappedjs.cpp @@ -237,7 +237,7 @@ do_decrement: if(0 == cnt) { - NS_DELETEXPCOM(this); // also unlinks us from chain + delete this; // also unlinks us from chain return 0; } if(1 == cnt) diff --git a/js/src/xpconnect/tests/components/xpctest_noisy.cpp b/js/src/xpconnect/tests/components/xpctest_noisy.cpp index 64057d65d65c..13090503ad51 100644 --- a/js/src/xpconnect/tests/components/xpctest_noisy.cpp +++ b/js/src/xpconnect/tests/components/xpctest_noisy.cpp @@ -77,7 +77,7 @@ NS_IMETHODIMP_(nsrefcnt) xpctestNoisy::Release(void) printf("Noisy %d - decremented refcount to %d\n", mID, mRefCnt.get()); NS_LOG_RELEASE(this, mRefCnt, "xpctestNoisy"); if (mRefCnt == 0) { - NS_DELETEXPCOM(this); + delete this; return 0; } return mRefCnt; diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index e46a45465e3d..84e5c35874ef 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -789,8 +789,7 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow) // // now register ourselves as a focus listener, so that we get called // when the focus changes in the window - nsDocViewerFocusListener *focusListener; - NS_NEWXPCOM(focusListener, nsDocViewerFocusListener); + nsDocViewerFocusListener *focusListener = new nsDocViewerFocusListener(); NS_ENSURE_TRUE(focusListener, NS_ERROR_OUT_OF_MEMORY); focusListener->Init(this); diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index 521a07efdd4a..66e7840b2130 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -591,15 +591,13 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \ { \ nsresult rv; \ \ - _InstanceClass * inst; \ - \ *aResult = NULL; \ if (NULL != aOuter) { \ rv = NS_ERROR_NO_AGGREGATION; \ return rv; \ } \ \ - NS_NEWXPCOM(inst, _InstanceClass); \ + _InstanceClass * inst = new _InstanceClass(); \ if (NULL == inst) { \ rv = NS_ERROR_OUT_OF_MEMORY; \ return rv; \ diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index 4e515ca4e3b0..6e73d2cb6e46 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -142,8 +142,7 @@ nsBulletFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) if (newRequest) { if (!mListener) { - nsBulletListener *listener; - NS_NEWXPCOM(listener, nsBulletListener); + nsBulletListener *listener = new nsBulletListener(); NS_ADDREF(listener); listener->SetFrame(this); listener->QueryInterface(NS_GET_IID(imgIDecoderObserver), getter_AddRefs(mListener)); diff --git a/layout/xul/base/src/nsImageBoxFrame.cpp b/layout/xul/base/src/nsImageBoxFrame.cpp index cc12f3801819..f7507527eef0 100644 --- a/layout/xul/base/src/nsImageBoxFrame.cpp +++ b/layout/xul/base/src/nsImageBoxFrame.cpp @@ -222,8 +222,7 @@ nsImageBoxFrame::Init(nsIContent* aContent, nsIFrame* aPrevInFlow) { if (!mListener) { - nsImageBoxListener *listener; - NS_NEWXPCOM(listener, nsImageBoxListener); + nsImageBoxListener *listener = new nsImageBoxListener(); NS_ADDREF(listener); listener->SetFrame(this); listener->QueryInterface(NS_GET_IID(imgIDecoderObserver), getter_AddRefs(mListener)); diff --git a/modules/libjar/nsJAR.cpp b/modules/libjar/nsJAR.cpp index a416ad3bd1ee..8a84bdf8a550 100644 --- a/modules/libjar/nsJAR.cpp +++ b/modules/libjar/nsJAR.cpp @@ -145,7 +145,7 @@ nsrefcnt nsJAR::Release(void) mRefCnt = 1; /* stabilize */ /* enable this to find non-threadsafe destructors: */ /* NS_ASSERT_OWNINGTHREAD(nsJAR); */ - NS_DELETEXPCOM(this); + delete this; return 0; } else if (1 == count && mCache) { diff --git a/modules/libpr0n/decoders/icon/nsIconProtocolHandler.cpp b/modules/libpr0n/decoders/icon/nsIconProtocolHandler.cpp index 6b50ca1c4c05..e3d0bfe2ae32 100644 --- a/modules/libpr0n/decoders/icon/nsIconProtocolHandler.cpp +++ b/modules/libpr0n/decoders/icon/nsIconProtocolHandler.cpp @@ -94,8 +94,7 @@ NS_IMETHODIMP nsIconProtocolHandler::NewURI(const nsACString &aSpec, nsIURI **result) { - nsCOMPtr uri; - NS_NEWXPCOM(uri, nsMozIconURI); + nsCOMPtr uri = new nsMozIconURI(); if (!uri) return NS_ERROR_OUT_OF_MEMORY; nsresult rv = uri->SetSpec(aSpec); diff --git a/modules/libpr0n/src/imgLoader.cpp b/modules/libpr0n/src/imgLoader.cpp index 00f6573a8e56..47360493f84f 100644 --- a/modules/libpr0n/src/imgLoader.cpp +++ b/modules/libpr0n/src/imgLoader.cpp @@ -661,7 +661,7 @@ nsresult imgLoader::CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup if (aProxyRequest) { proxyRequest = static_cast(aProxyRequest); } else { - NS_NEWXPCOM(proxyRequest, imgRequestProxy); + proxyRequest = new imgRequestProxy(); if (!proxyRequest) return NS_ERROR_OUT_OF_MEMORY; } NS_ADDREF(proxyRequest); diff --git a/modules/libpr0n/src/imgTools.cpp b/modules/libpr0n/src/imgTools.cpp index 870bc8f79463..7b3020ac7cc2 100644 --- a/modules/libpr0n/src/imgTools.cpp +++ b/modules/libpr0n/src/imgTools.cpp @@ -80,7 +80,7 @@ NS_IMETHODIMP imgTools::DecodeImageData(nsIInputStream* aInStr, NS_ENSURE_ARG_POINTER(aInStr); // If the caller didn't provide a container, create one if (!*aContainer) { - NS_NEWXPCOM(*aContainer, imgContainer); + *aContainer = new imgContainer(); if (!*aContainer) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(*aContainer); diff --git a/netwerk/base/src/nsMIMEInputStream.cpp b/netwerk/base/src/nsMIMEInputStream.cpp index 9a69ffd2c0a6..061b8778be71 100644 --- a/netwerk/base/src/nsMIMEInputStream.cpp +++ b/netwerk/base/src/nsMIMEInputStream.cpp @@ -288,8 +288,7 @@ nsMIMEInputStreamConstructor(nsISupports *outer, REFNSIID iid, void **result) if (outer) return NS_ERROR_NO_AGGREGATION; - nsMIMEInputStream *inst; - NS_NEWXPCOM(inst, nsMIMEInputStream); + nsMIMEInputStream *inst = new nsMIMEInputStream(); if (!inst) return NS_ERROR_OUT_OF_MEMORY; diff --git a/netwerk/base/src/nsStandardURL.cpp b/netwerk/base/src/nsStandardURL.cpp index 4bc839084aa6..bd911fb3de5f 100644 --- a/netwerk/base/src/nsStandardURL.cpp +++ b/netwerk/base/src/nsStandardURL.cpp @@ -1675,8 +1675,7 @@ nsStandardURL::SchemeIs(const char *scheme, PRBool *result) /* virtual */ nsStandardURL* nsStandardURL::StartClone() { - nsStandardURL *clone; - NS_NEWXPCOM(clone, nsStandardURL); + nsStandardURL *clone = new nsStandardURL(); return clone; } diff --git a/netwerk/protocol/res/nsResProtocolHandler.cpp b/netwerk/protocol/res/nsResProtocolHandler.cpp index 1961c21457e9..a55ca5511f34 100644 --- a/netwerk/protocol/res/nsResProtocolHandler.cpp +++ b/netwerk/protocol/res/nsResProtocolHandler.cpp @@ -133,8 +133,7 @@ nsResURL::EnsureFile() /* virtual */ nsStandardURL* nsResURL::StartClone() { - nsResURL *clone; - NS_NEWXPCOM(clone, nsResURL); + nsResURL *clone = new nsResURL(); return clone; } @@ -336,8 +335,7 @@ nsResProtocolHandler::NewURI(const nsACString &aSpec, { nsresult rv; - nsResURL *resURL; - NS_NEWXPCOM(resURL, nsResURL); + nsResURL *resURL = new nsResURL(); if (!resURL) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(resURL); diff --git a/security/manager/ssl/src/nsNSSModule.cpp b/security/manager/ssl/src/nsNSSModule.cpp index 8bff311a31ec..a9499331a0dc 100644 --- a/security/manager/ssl/src/nsNSSModule.cpp +++ b/security/manager/ssl/src/nsNSSModule.cpp @@ -106,7 +106,7 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \ return NS_ERROR_FAILURE; \ } \ \ - NS_NEWXPCOM(inst, _InstanceClass); \ + inst = new _InstanceClass(); \ if (NULL == inst) { \ if (triggeredByNSSComponent) \ EnsureNSSInitialized(nssInitFailed); \ @@ -155,7 +155,7 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \ return NS_ERROR_FAILURE; \ } \ \ - NS_NEWXPCOM(inst, _InstanceClass); \ + inst = new _InstanceClass(); \ if (NULL == inst) { \ if (triggeredByNSSComponent) \ EnsureNSSInitialized(nssInitFailed); \ diff --git a/uriloader/exthandler/nsExternalProtocolHandler.cpp b/uriloader/exthandler/nsExternalProtocolHandler.cpp index d6834cbe284a..fac8a26822b6 100644 --- a/uriloader/exthandler/nsExternalProtocolHandler.cpp +++ b/uriloader/exthandler/nsExternalProtocolHandler.cpp @@ -401,8 +401,7 @@ NS_IMETHODIMP nsExternalProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **_ PRBool haveExternalHandler = HaveExternalProtocolHandler(aURI); if (haveExternalHandler) { - nsCOMPtr channel; - NS_NEWXPCOM(channel, nsExtProtocolChannel); + nsCOMPtr channel = new nsExtProtocolChannel(); if (!channel) return NS_ERROR_OUT_OF_MEMORY; ((nsExtProtocolChannel*) channel.get())->SetURI(aURI); diff --git a/widget/src/gtk2/nsGtkIMModule.h b/widget/src/gtk2/nsGtkIMModule.h index 7287ee2d83df..161167fec8e6 100644 --- a/widget/src/gtk2/nsGtkIMModule.h +++ b/widget/src/gtk2/nsGtkIMModule.h @@ -73,7 +73,7 @@ public: NS_LOG_RELEASE(this, mRefCnt, "nsGtkIMModule"); if (mRefCnt == 0) { mRefCnt = 1; /* stabilize */ - NS_DELETEXPCOM(this); + delete this; return 0; } return mRefCnt; diff --git a/widget/src/gtk2/nsWidgetFactory.cpp b/widget/src/gtk2/nsWidgetFactory.cpp index b525ca278019..e556bb34955d 100644 --- a/widget/src/gtk2/nsWidgetFactory.cpp +++ b/widget/src/gtk2/nsWidgetFactory.cpp @@ -123,7 +123,7 @@ nsNativeThemeGTKConstructor(nsISupports *aOuter, REFNSIID aIID, return rv; } - NS_NEWXPCOM(inst, nsNativeThemeGTK); + inst = new nsNativeThemeGTK(); if (NULL == inst) { rv = NS_ERROR_OUT_OF_MEMORY; return rv; @@ -197,7 +197,7 @@ nsNativeKeyBindingsConstructor(nsISupports *aOuter, REFNSIID aIID, return rv; } - NS_NEWXPCOM(inst, nsNativeKeyBindings); + inst = new nsNativeKeyBindings(); if (NULL == inst) { rv = NS_ERROR_OUT_OF_MEMORY; return rv; diff --git a/widget/src/os2/nsRwsService.cpp b/widget/src/os2/nsRwsService.cpp index a20555c0e8f3..c6207771324a 100644 --- a/widget/src/os2/nsRwsService.cpp +++ b/widget/src/os2/nsRwsService.cpp @@ -1217,7 +1217,7 @@ static nsresult nsRwsServiceInit(nsRwsService **aClass) } // create an instance of nsRwsService - NS_NEWXPCOM(sRwsInstance, nsRwsService); + sRwsInstance = new nsRwsService(); if (sRwsInstance == 0) return NS_ERROR_OUT_OF_MEMORY; diff --git a/widget/src/qt/nsWidgetFactory.cpp b/widget/src/qt/nsWidgetFactory.cpp index a5a159e0ba45..aa7afe688d71 100644 --- a/widget/src/qt/nsWidgetFactory.cpp +++ b/widget/src/qt/nsWidgetFactory.cpp @@ -95,7 +95,7 @@ nsNativeThemeQtConstructor(nsISupports *aOuter, REFNSIID aIID, if (NULL != aOuter) return NS_ERROR_NO_AGGREGATION; - NS_NEWXPCOM(inst, nsNativeThemeQt); + inst = new nsNativeThemeQt(); if (NULL == inst) return NS_ERROR_OUT_OF_MEMORY; diff --git a/xpcom/base/nsAgg.h b/xpcom/base/nsAgg.h index 2b463283db09..202bc4da5d2b 100644 --- a/xpcom/base/nsAgg.h +++ b/xpcom/base/nsAgg.h @@ -155,7 +155,7 @@ _class::Internal::Release(void) \ NS_LOG_RELEASE(this, agg->mRefCnt, #_class); \ if (agg->mRefCnt == 0) { \ agg->mRefCnt = 1; /* stabilize */ \ - NS_DELETEXPCOM(agg); \ + delete agg; \ return 0; \ } \ return agg->mRefCnt; \ @@ -188,7 +188,7 @@ _class::Internal::Release(void) \ NS_LOG_RELEASE(this, count, #_class); \ if (count == 0) { \ agg->mRefCnt.stabilizeForDeletion(this); \ - NS_DELETEXPCOM(agg); \ + delete agg; \ return 0; \ } \ return count; \ diff --git a/xpcom/base/nsTraceRefcntImpl.cpp b/xpcom/base/nsTraceRefcntImpl.cpp index d56b6d75a99c..c22f1dc459b7 100644 --- a/xpcom/base/nsTraceRefcntImpl.cpp +++ b/xpcom/base/nsTraceRefcntImpl.cpp @@ -984,7 +984,7 @@ NS_LogAddRef(void* aPtr, nsrefcnt aRefcnt, } } - // Here's the case where neither NS_NEWXPCOM nor MOZ_COUNT_CTOR were used, + // Here's the case where MOZ_COUNT_CTOR was not used, // yet we still want to see creation information: PRBool loggingThisType = (!gTypesToLog || LogThisType(aClazz)); @@ -1068,7 +1068,7 @@ NS_LogRelease(void* aPtr, nsrefcnt aRefcnt, const char* aClazz) } } - // Here's the case where neither NS_DELETEXPCOM nor MOZ_COUNT_DTOR were used, + // Here's the case where MOZ_COUNT_DTOR was not used, // yet we still want to see deletion information: if (aRefcnt == 0 && gAllocLog && loggingThisType && loggingThisObject) { diff --git a/xpcom/glue/nsISupportsImpl.h b/xpcom/glue/nsISupportsImpl.h index 69c5ed10b983..e3b1701e4ba2 100644 --- a/xpcom/glue/nsISupportsImpl.h +++ b/xpcom/glue/nsISupportsImpl.h @@ -327,7 +327,7 @@ public: \ NS_LOG_RELEASE(this, mRefCnt, #_class); \ if (mRefCnt == 0) { \ mRefCnt = 1; /* stabilize */ \ - NS_DELETEXPCOM(this); \ + delete this; \ } \ } \ protected: \ @@ -411,7 +411,7 @@ NS_IMETHODIMP_(nsrefcnt) _class::Release(void) \ * the refcount to |0|. */ #define NS_IMPL_RELEASE(_class) \ - NS_IMPL_RELEASE_WITH_DESTROY(_class, NS_DELETEXPCOM(this)) + NS_IMPL_RELEASE_WITH_DESTROY(_class, delete (this)) /** * Use this macro to implement the Release method for a given _class @@ -465,10 +465,10 @@ NS_IMETHODIMP_(nsrefcnt) _class::Release(void) \ NS_IMPL_CYCLE_COLLECTING_RELEASE_FULL(_class, _basetype, _destroy) #define NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS(_class, _basetype) \ - NS_IMPL_CYCLE_COLLECTING_RELEASE_FULL(_class, _basetype, NS_DELETEXPCOM(this)) + NS_IMPL_CYCLE_COLLECTING_RELEASE_FULL(_class, _basetype, delete (this)) #define NS_IMPL_CYCLE_COLLECTING_RELEASE(_class) \ - NS_IMPL_CYCLE_COLLECTING_RELEASE_FULL(_class, _class, NS_DELETEXPCOM(this)) + NS_IMPL_CYCLE_COLLECTING_RELEASE_FULL(_class, _class, delete (this)) /////////////////////////////////////////////////////////////////////////////// @@ -1278,7 +1278,7 @@ NS_IMETHODIMP_(nsrefcnt) _class::Release(void) \ mRefCnt = 1; /* stabilize */ \ /* enable this to find non-threadsafe destructors: */ \ /* NS_ASSERT_OWNINGTHREAD(_class); */ \ - NS_DELETEXPCOM(this); \ + delete (this); \ return 0; \ } \ return count; \ diff --git a/xpcom/glue/nsISupportsUtils.h b/xpcom/glue/nsISupportsUtils.h index 7bfb89494650..f3dbeec9e978 100644 --- a/xpcom/glue/nsISupportsUtils.h +++ b/xpcom/glue/nsISupportsUtils.h @@ -61,27 +61,6 @@ #include "nsISupportsImpl.h" #endif -/** - * Macro for instantiating a new object that implements nsISupports. - * Note that you can only use this if you adhere to the no arguments - * constructor com policy (which you really should!). - * @param _result Where the new instance pointer is stored - * @param _type The type of object to call "new" with. - */ -#define NS_NEWXPCOM(_result,_type) \ - PR_BEGIN_MACRO \ - _result = new _type(); \ - PR_END_MACRO - -/** - * Macro for deleting an object that implements nsISupports. - * @param _ptr The object to delete. - */ -#define NS_DELETEXPCOM(_ptr) \ - PR_BEGIN_MACRO \ - delete (_ptr); \ - PR_END_MACRO - /** * Macro for adding a reference to an interface. * @param _ptr The interface pointer. diff --git a/xpcom/io/nsInputStreamTee.cpp b/xpcom/io/nsInputStreamTee.cpp index 7500c52ad0a4..99c906444a3a 100644 --- a/xpcom/io/nsInputStreamTee.cpp +++ b/xpcom/io/nsInputStreamTee.cpp @@ -306,8 +306,7 @@ NS_NewInputStreamTeeAsync(nsIInputStream **result, { nsresult rv; - nsCOMPtr tee; - NS_NEWXPCOM(tee, nsInputStreamTee); + nsCOMPtr tee = new nsInputStreamTee(); if (!tee) return NS_ERROR_OUT_OF_MEMORY; diff --git a/xpcom/io/nsMultiplexInputStream.cpp b/xpcom/io/nsMultiplexInputStream.cpp index 1697abd64ae5..254f59aaafee 100644 --- a/xpcom/io/nsMultiplexInputStream.cpp +++ b/xpcom/io/nsMultiplexInputStream.cpp @@ -398,8 +398,7 @@ nsMultiplexInputStreamConstructor(nsISupports *outer, if (outer) return NS_ERROR_NO_AGGREGATION; - nsMultiplexInputStream *inst; - NS_NEWXPCOM(inst, nsMultiplexInputStream); + nsMultiplexInputStream *inst = new nsMultiplexInputStream(); if (!inst) return NS_ERROR_OUT_OF_MEMORY; diff --git a/xpcom/proxy/src/nsProxyEventObject.cpp b/xpcom/proxy/src/nsProxyEventObject.cpp index 7dab1773c802..08b38bba82b0 100644 --- a/xpcom/proxy/src/nsProxyEventObject.cpp +++ b/xpcom/proxy/src/nsProxyEventObject.cpp @@ -113,7 +113,7 @@ nsProxyEventObject::Release(void) // call the destructor outside of the lock so that we aren't holding the // lock when we release the object - NS_DELETEXPCOM(this); + delete this; return 0; } diff --git a/xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp b/xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp index ca1c04da006f..b6ed09e6c279 100644 --- a/xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp +++ b/xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp @@ -699,7 +699,7 @@ xptiInterfaceInfo::Release(void) mEntry = nsnull; } - NS_DELETEXPCOM(this); + delete this; return 0; } return cnt; diff --git a/xpcom/tests/TestCOMArray.cpp b/xpcom/tests/TestCOMArray.cpp index 8df7c2411eb4..40ca258a758e 100644 --- a/xpcom/tests/TestCOMArray.cpp +++ b/xpcom/tests/TestCOMArray.cpp @@ -150,7 +150,7 @@ Bar::Release(void) NS_LOG_RELEASE(this, mRefCnt, "Bar"); if (mRefCnt == 0) { mRefCnt = 1; /* stabilize */ - NS_DELETEXPCOM(this); + delete this; return 0; } return mRefCnt; diff --git a/xpcom/threads/nsTimerImpl.cpp b/xpcom/threads/nsTimerImpl.cpp index 6fa8410df074..f2dd88674c89 100644 --- a/xpcom/threads/nsTimerImpl.cpp +++ b/xpcom/threads/nsTimerImpl.cpp @@ -91,7 +91,7 @@ NS_IMETHODIMP_(nsrefcnt) nsTimerImpl::Release(void) /* enable this to find non-threadsafe destructors: */ /* NS_ASSERT_OWNINGTHREAD(nsTimerImpl); */ - NS_DELETEXPCOM(this); + delete this; return 0; }