Bug 562387 - Convert NS_NEWXPCOM/NS_DELETEXPCOM to new/delete. r=bsmedberg

This commit is contained in:
Saint Wesonga 2010-07-04 21:39:17 +02:00
Родитель 2b76dedfb6
Коммит 8952503f91
47 изменённых файлов: 64 добавлений и 111 удалений

Просмотреть файл

@ -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;
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -1360,8 +1360,7 @@ nsXMLHttpRequest::GetAllResponseHeaders(char **_retval)
nsCOMPtr<nsIHttpChannel> 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);

Просмотреть файл

@ -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<nsIXMLContentSink> kungFuDeathGrip = it;

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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<nsIControllerCommand *>(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<nsIControllerCommand *>(theCmd));

Просмотреть файл

@ -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<nsIControllerCommand *>(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<nsIControllerCommand *>(theCmd));

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<nsIControllerCommand *>(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<nsIControllerCommand *>(theCmd));

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<nsWebBrowserListenerState> 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<nsWebBrowserListenerState*>);
mListenerArray = new nsTArray<nsWebBrowserListenerState*>();
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;
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -74,8 +74,7 @@ nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult
return rv;
}
nsCOMPtr <nsIRegion> rgn;
NS_NEWXPCOM(rgn, nsThebesRegion);
nsCOMPtr <nsIRegion> rgn = new nsThebesRegion();
nsCOMPtr<nsIScriptableRegion> scriptableRgn;
if (rgn != nsnull)
{

Просмотреть файл

@ -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; \

Просмотреть файл

@ -164,7 +164,7 @@ static nsCompressedMap gLowerMap = {
nsCaseConversionImp2* nsCaseConversionImp2::GetInstance()
{
if (!gCaseConv)
NS_NEWXPCOM(gCaseConv, nsCaseConversionImp2);
gCaseConv = new nsCaseConversionImp2();
return gCaseConv;
}

Просмотреть файл

@ -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)

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);

Просмотреть файл

@ -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; \

Просмотреть файл

@ -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));

Просмотреть файл

@ -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));

Просмотреть файл

@ -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) {

Просмотреть файл

@ -94,8 +94,7 @@ NS_IMETHODIMP nsIconProtocolHandler::NewURI(const nsACString &aSpec,
nsIURI **result)
{
nsCOMPtr<nsIURI> uri;
NS_NEWXPCOM(uri, nsMozIconURI);
nsCOMPtr<nsIURI> uri = new nsMozIconURI();
if (!uri) return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = uri->SetSpec(aSpec);

Просмотреть файл

@ -661,7 +661,7 @@ nsresult imgLoader::CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup
if (aProxyRequest) {
proxyRequest = static_cast<imgRequestProxy *>(aProxyRequest);
} else {
NS_NEWXPCOM(proxyRequest, imgRequestProxy);
proxyRequest = new imgRequestProxy();
if (!proxyRequest) return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(proxyRequest);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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); \

Просмотреть файл

@ -401,8 +401,7 @@ NS_IMETHODIMP nsExternalProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **_
PRBool haveExternalHandler = HaveExternalProtocolHandler(aURI);
if (haveExternalHandler)
{
nsCOMPtr<nsIChannel> channel;
NS_NEWXPCOM(channel, nsExtProtocolChannel);
nsCOMPtr<nsIChannel> channel = new nsExtProtocolChannel();
if (!channel) return NS_ERROR_OUT_OF_MEMORY;
((nsExtProtocolChannel*) channel.get())->SetURI(aURI);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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; \

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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 <i>_class</i>
@ -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; \

Просмотреть файл

@ -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.

Просмотреть файл

@ -306,8 +306,7 @@ NS_NewInputStreamTeeAsync(nsIInputStream **result,
{
nsresult rv;
nsCOMPtr<nsIInputStreamTee> tee;
NS_NEWXPCOM(tee, nsInputStreamTee);
nsCOMPtr<nsIInputStreamTee> tee = new nsInputStreamTee();
if (!tee)
return NS_ERROR_OUT_OF_MEMORY;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -699,7 +699,7 @@ xptiInterfaceInfo::Release(void)
mEntry = nsnull;
}
NS_DELETEXPCOM(this);
delete this;
return 0;
}
return cnt;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;
}