stack-comptr-fixup
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 153 cd96178a2e472dc6cd10443a56a3cedf9e8e1140
permissions -rw-r--r--
State as of now

* * *
* * *

diff --git a/content/base/src/nsGenericElement.h b/content/base/src/nsGenericElement.h
--- a/content/base/src/nsGenericElement.h
+++ b/content/base/src/nsGenericElement.h
@@ -999,10 +999,9 @@ _elementName::Clone(nsINodeInfo *aNodeIn
     return NS_ERROR_OUT_OF_MEMORY;                                          \
   }                                                                         \
                                                                             \
-  nsCOMPtr<nsINode> kungFuDeathGrip = it;                                   \
   nsresult rv = CopyInnerTo(it);                                            \
   if (NS_SUCCEEDED(rv)) {                                                   \
-    kungFuDeathGrip.swap(*aResult);                                         \
+    *aResult = it;                                                          \
   }                                                                         \
                                                                             \
   return rv;                                                                \
@@ -1019,11 +1018,10 @@ _elementName::Clone(nsINodeInfo *aNodeIn
     return NS_ERROR_OUT_OF_MEMORY;                                          \
   }                                                                         \
                                                                             \
-  nsCOMPtr<nsINode> kungFuDeathGrip = it;                                   \
   nsresult rv = it->Init();                                                 \
   rv |= CopyInnerTo(it);                                                    \
   if (NS_SUCCEEDED(rv)) {                                                   \
-    kungFuDeathGrip.swap(*aResult);                                         \
+    *aResult = it;                                                          \
   }                                                                         \
                                                                             \
   return rv;                                                                \
diff --git a/content/html/content/src/nsHTMLTableElement.cpp b/content/html/content/src/nsHTMLTableElement.cpp
--- a/content/html/content/src/nsHTMLTableElement.cpp
+++ b/content/html/content/src/nsHTMLTableElement.cpp
@@ -175,34 +175,34 @@ TableRowsCollection::Init()
   PR_BEGIN_MACRO                                                     \
     if (mParent) {                                                   \
       /* THead */                                                    \
-      nsCOMPtr<nsIDOMHTMLTableSectionElement> rowGroup;              \
-      rv = mParent->GetTHead(getter_AddRefs(rowGroup));              \
+      nsIDOMHTMLTableSectionElement* rowGroup = nsnull;              \
+      rv = mParent->GetTHead(&rowGroup);                             \
       NS_ENSURE_SUCCESS(rv, rv);                                     \
-      nsCOMPtr<nsIDOMHTMLCollection> rows;                           \
+      nsIDOMHTMLCollection* rows = nsnull;                           \
       if (rowGroup) {                                                \
-        rowGroup->GetRows(getter_AddRefs(rows));                     \
+        rowGroup->GetRows(&rows);                                    \
         do { /* gives scoping */                                     \
           _code                                                      \
         } while (0);                                                 \
       }                                                              \
-      nsCOMPtr<nsIDOMHTMLCollection> _tbodies;                       \
+      nsIDOMHTMLCollection* _tbodies = nsnull;                       \
       /* TBodies */                                                  \
-      rv = mParent->GetTBodies(getter_AddRefs(_tbodies));            \
+      rv = mParent->GetTBodies(&_tbodies);                           \
       NS_ENSURE_SUCCESS(rv, rv);                                     \
       if (_tbodies) {                                                \
-        nsCOMPtr<nsIDOMNode> _node;                                  \
+        nsIDOMNode* _node = nsnull;                                  \
         PRUint32 _tbodyIndex = 0;                                    \
-        rv = _tbodies->Item(_tbodyIndex, getter_AddRefs(_node));     \
+        rv = _tbodies->Item(_tbodyIndex, &_node);                    \
         NS_ENSURE_SUCCESS(rv, rv);                                   \
         while (_node) {                                              \
           rowGroup = do_QueryInterface(_node);                       \
           if (rowGroup) {                                            \
-            rowGroup->GetRows(getter_AddRefs(rows));                 \
+            rowGroup->GetRows(&rows);                                \
             do { /* gives scoping */                                 \
               _code                                                  \
             } while (0);                                             \
           }                                                          \
-          rv = _tbodies->Item(++_tbodyIndex, getter_AddRefs(_node)); \
+          rv = _tbodies->Item(++_tbodyIndex, &_node);                \
           NS_ENSURE_SUCCESS(rv, rv);                                 \
         }                                                            \
       }                                                              \
@@ -212,11 +212,11 @@ TableRowsCollection::Init()
         _code                                                        \
       } while (0);                                                   \
       /* TFoot */                                                    \
-      rv = mParent->GetTFoot(getter_AddRefs(rowGroup));              \
+      rv = mParent->GetTFoot(&rowGroup);                             \
       NS_ENSURE_SUCCESS(rv, rv);                                     \
       rows = nsnull;                                                 \
       if (rowGroup) {                                                \
-        rowGroup->GetRows(getter_AddRefs(rows));                     \
+        rowGroup->GetRows(&rows);                                    \
         do { /* gives scoping */                                     \
           _code                                                      \
         } while (0);                                                 \
diff --git a/content/xbl/src/nsBindingManager.cpp b/content/xbl/src/nsBindingManager.cpp
--- a/content/xbl/src/nsBindingManager.cpp
+++ b/content/xbl/src/nsBindingManager.cpp
@@ -425,7 +425,7 @@ nsBindingManager::SetBinding(nsIContent*
   // constructor twice (if aBinding inherits from it) or firing its constructor
   // after aContent has been deleted (if aBinding is null and the content node
   // dies before we process mAttachedStack).
-  nsRefPtr<nsXBLBinding> oldBinding = GetBinding(aContent);
+  nsXBLBinding* oldBinding = GetBinding(aContent);
   if (oldBinding) {
     if (aContent->HasFlag(NODE_IS_INSERTION_PARENT)) {
       nsRefPtr<nsXBLBinding> parentBinding =
diff --git a/dom/public/nsIDOMClassInfo.h b/dom/public/nsIDOMClassInfo.h
--- a/dom/public/nsIDOMClassInfo.h
+++ b/dom/public/nsIDOMClassInfo.h
@@ -94,8 +94,8 @@ typedef nsIClassInfo* (*nsDOMClassInfoEx
     static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);   \
                                                                            \
     nsresult rv;                                                           \
-    nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID,     \
-                                                          &rv));           \
+    nsIDOMScriptObjectFactory* sof(do_GetService(kDOMSOF_CID,              \
+                                                 &rv));                    \
     if (NS_FAILED(rv)) {                                                   \
       *aInstancePtr = nsnull;                                              \
       return rv;                                                           \
@@ -117,8 +117,8 @@ typedef nsIClassInfo* (*nsDOMClassInfoEx
       static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); \
                                                                            \
       nsresult rv;                                                         \
-      nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID,   \
-                                                            &rv));         \
+      nsIDOMScriptObjectFactory* sof(do_GetService(kDOMSOF_CID,            \
+                                                   &rv));                  \
       if (NS_FAILED(rv)) {                                                 \
         *aInstancePtr = nsnull;                                            \
         return rv;                                                         \
diff --git a/dom/src/base/nsDOMScriptObjectFactory.cpp b/dom/src/base/nsDOMScriptObjectFactory.cpp
--- a/dom/src/base/nsDOMScriptObjectFactory.cpp
+++ b/dom/src/base/nsDOMScriptObjectFactory.cpp
@@ -394,7 +394,7 @@ nsresult NS_GetScriptRuntime(const nsASt
 {
   nsresult rv;
   *aLanguage = nsnull;
-  nsCOMPtr<nsIDOMScriptObjectFactory> factory = \
+  nsCOMPtr<nsIDOMScriptObjectFactory> factory =
         do_GetService(kDOMScriptObjectFactoryCID, &rv);
   if (NS_FAILED(rv))
     return rv;
@@ -406,7 +406,7 @@ nsresult NS_GetScriptRuntimeByID(PRUint3
 {
   nsresult rv;
   *aLanguage = nsnull;
-  nsCOMPtr<nsIDOMScriptObjectFactory> factory = \
+  nsCOMPtr<nsIDOMScriptObjectFactory> factory =
         do_GetService(kDOMScriptObjectFactoryCID, &rv);
   if (NS_FAILED(rv))
     return rv;
diff --git a/dom/src/jsurl/nsJSProtocolHandler.cpp b/dom/src/jsurl/nsJSProtocolHandler.cpp
--- a/dom/src/jsurl/nsJSProtocolHandler.cpp
+++ b/dom/src/jsurl/nsJSProtocolHandler.cpp
@@ -135,8 +135,8 @@ nsIScriptGlobalObject* GetGlobalObject(n
 nsIScriptGlobalObject* GetGlobalObject(nsIChannel* aChannel)
 {
     // Get the global object owner from the channel
-    nsCOMPtr<nsIScriptGlobalObjectOwner> globalOwner;
-    NS_QueryNotificationCallbacks(aChannel, globalOwner);
+    nsIScriptGlobalObjectOwner* globalOwner = nsnull;
+    NS_QueryNotificationCallbacks(aChannel, &globalOwner);
     NS_ASSERTION(globalOwner, 
                  "Unable to get an nsIScriptGlobalObjectOwner from the "
                  "channel!");
@@ -166,9 +166,9 @@ nsresult nsJSThunk::EvaluateScript(nsICh
     NS_ENSURE_ARG_POINTER(aChannel);
 
     // Get principal of code for execution
-    nsCOMPtr<nsISupports> owner;
-    aChannel->GetOwner(getter_AddRefs(owner));
-    nsCOMPtr<nsIPrincipal> principal = do_QueryInterface(owner);
+    nsISupports* owner = nsnull;
+    aChannel->GetOwner(&owner);
+    nsIPrincipal* principal = do_QueryInterface(owner);
     if (!principal) {
         // No execution without a principal!
         NS_ASSERTION(!owner, "Non-principal owner?");
@@ -187,7 +187,7 @@ nsresult nsJSThunk::EvaluateScript(nsICh
         return NS_ERROR_FAILURE;
     }
 
-    nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(global));
+    nsPIDOMWindow* win(do_QueryInterface(global));
 
     // Push our popup control state
     nsAutoPopupStatePusher popupStatePusher(win, aPopupState);
@@ -199,17 +199,17 @@ nsresult nsJSThunk::EvaluateScript(nsICh
         return NS_ERROR_UNEXPECTED;
     }
 
-    nsCOMPtr<nsIScriptGlobalObject> innerGlobal = do_QueryInterface(innerWin);
+    nsIScriptGlobalObject* innerGlobal = do_QueryInterface(innerWin);
 
     JSObject *globalJSObject = innerGlobal->GetGlobalJSObject();
 
-    nsCOMPtr<nsIDOMWindow> domWindow(do_QueryInterface(global, &rv));
+    nsIDOMWindow* domWindow(do_QueryInterface(global, &rv));
     if (NS_FAILED(rv)) {
         return NS_ERROR_FAILURE;
     }
 
     // So far so good: get the script context from its owner.
-    nsCOMPtr<nsIScriptContext> scriptContext = global->GetContext();
+    nsIScriptContext* scriptContext = global->GetContext();
     if (!scriptContext)
         return NS_ERROR_FAILURE;
 
@@ -221,8 +221,8 @@ nsresult nsJSThunk::EvaluateScript(nsICh
     rv = mURI->GetSpec(url);
     if (NS_FAILED(rv)) return rv;
 
-    nsCOMPtr<nsIScriptSecurityManager> securityManager;
-    securityManager = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
+    nsIScriptSecurityManager* securityManager =
+        do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
     if (NS_FAILED(rv))
         return rv;
 
@@ -232,11 +232,11 @@ nsresult nsJSThunk::EvaluateScript(nsICh
     if (!useSandbox) {
         //-- Don't outside a sandbox unless the script principal subsumes the
         //   principal of the context.
-        nsCOMPtr<nsIPrincipal> objectPrincipal;
+        nsIPrincipal* objectPrincipal = nsnull;
         rv = securityManager->
             GetObjectPrincipal((JSContext*)scriptContext->GetNativeContext(),
                                globalJSObject,
-                               getter_AddRefs(objectPrincipal));
+                               &objectPrincipal);
         if (NS_FAILED(rv))
             return rv;
 
@@ -278,8 +278,8 @@ nsresult nsJSThunk::EvaluateScript(nsICh
 
         nsIXPConnect *xpc = nsContentUtils::XPConnect();
 
-        nsCOMPtr<nsIXPConnectJSObjectHolder> sandbox;
-        rv = xpc->CreateSandbox(cx, principal, getter_AddRefs(sandbox));
+        nsIXPConnectJSObjectHolder* sandbox = nsnull;
+        rv = xpc->CreateSandbox(cx, principal, &sandbox);
         NS_ENSURE_SUCCESS(rv, rv);
 
         jsval rval = JSVAL_VOID;
@@ -291,7 +291,7 @@ nsresult nsJSThunk::EvaluateScript(nsICh
         // Push our JSContext on the context stack so the JS_ValueToString call (and
         // JS_ReportPendingException, if relevant) will use the principal of cx.
         // Note that we do this as late as possible to make popping simpler.
-        nsCOMPtr<nsIJSContextStack> stack =
+        nsIJSContextStack* stack =
             do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
         if (NS_SUCCEEDED(rv)) {
             rv = stack->Push(cx);
@@ -450,8 +450,8 @@ nsresult nsJSChannel::StopAll()
 nsresult nsJSChannel::StopAll()
 {
     nsresult rv = NS_ERROR_UNEXPECTED;
-    nsCOMPtr<nsIWebNavigation> webNav;
-    NS_QueryNotificationCallbacks(mStreamChannel, webNav);
+    nsIWebNavigation* webNav = nsnull;
+    NS_QueryNotificationCallbacks(mStreamChannel, &webNav);
 
     NS_ASSERTION(webNav, "Can't get nsIWebNavigation from channel!");
     if (webNav) {
@@ -473,11 +473,11 @@ nsresult nsJSChannel::Init(nsIURI *aURI)
     // Create a stock input stream channel...
     // Remember, until AsyncOpen is called, the script will not be evaluated
     // and the underlying Input Stream will not be created...
-    nsCOMPtr<nsIChannel> channel;
+    nsIChannel* channel = nsnull;
 
     // If the resultant script evaluation actually does return a value, we
     // treat it as html.
-    rv = NS_NewInputStreamChannel(getter_AddRefs(channel), aURI, mIOThunk,
+    rv = NS_NewInputStreamChannel(&channel, aURI, mIOThunk,
                                   NS_LITERAL_CSTRING("text/html"));
     if (NS_FAILED(rv)) return rv;
 
@@ -603,7 +603,7 @@ nsJSChannel::AsyncOpen(nsIStreamListener
         return NS_ERROR_NOT_AVAILABLE;
     }
 
-    nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(global));
+    nsPIDOMWindow* win(do_QueryInterface(global));
     NS_ASSERTION(win, "Our global is not a window??");
 
     // Make sure we create a new inner window if one doesn't already exist (see
@@ -628,8 +628,8 @@ nsJSChannel::AsyncOpen(nsIStreamListener
 
     // Add the javascript channel to its loadgroup so that we know if
     // network loads were canceled or not...
-    nsCOMPtr<nsILoadGroup> loadGroup;
-    mStreamChannel->GetLoadGroup(getter_AddRefs(loadGroup));
+    nsILoadGroup* loadGroup = nsnull;
+    mStreamChannel->GetLoadGroup(&loadGroup);
     if (loadGroup) {
         nsresult rv = loadGroup->AddRequest(this, nsnull);
         if (NS_FAILED(rv)) {
@@ -692,7 +692,7 @@ nsJSChannel::AsyncOpen(nsIStreamListener
         method = &nsJSChannel::NotifyListener;            
     }
 
-    nsCOMPtr<nsIRunnable> ev = new nsRunnableMethod<nsJSChannel>(this, method);
+    nsIRunnable* ev = new nsRunnableMethod<nsJSChannel>(this, method);
     nsresult rv = NS_DispatchToCurrentThread(ev);
 
     if (NS_FAILED(rv)) {
@@ -728,8 +728,8 @@ nsJSChannel::EvaluateScript()
     }
     
     // Remove the javascript channel from its loadgroup...
-    nsCOMPtr<nsILoadGroup> loadGroup;
-    mStreamChannel->GetLoadGroup(getter_AddRefs(loadGroup));
+    nsILoadGroup* loadGroup = nsnull; 
+    mStreamChannel->GetLoadGroup(&loadGroup);
     if (loadGroup) {
         loadGroup->RemoveRequest(this, nsnull, mStatus);
     }
@@ -761,11 +761,11 @@ nsJSChannel::EvaluateScript()
         // we'll blow away the current document. Make sure that's
         // ok. If so, stop all pending network loads.
 
-        nsCOMPtr<nsIDocShell> docShell;
-        NS_QueryNotificationCallbacks(mStreamChannel, docShell);
+        nsIDocShell *docShell = nsnull;
+        NS_QueryNotificationCallbacks(mStreamChannel, &docShell);
         if (docShell) {
-            nsCOMPtr<nsIContentViewer> cv;
-            docShell->GetContentViewer(getter_AddRefs(cv));
+            nsIContentViewer* cv = nsnull;
+            docShell->GetContentViewer(&cv);
 
             if (cv) {
                 PRBool okToUnload;
@@ -882,8 +882,8 @@ nsJSChannel::SetLoadGroup(nsILoadGroup* 
         NS_ENSURE_SUCCESS(rv, rv);
 
         if (streamPending) {
-            nsCOMPtr<nsILoadGroup> curLoadGroup;
-            mStreamChannel->GetLoadGroup(getter_AddRefs(curLoadGroup));
+            nsILoadGroup* curLoadGroup = nsnull;
+            mStreamChannel->GetLoadGroup(&curLoadGroup);
 
             if (aLoadGroup != curLoadGroup) {
                 // Move the stream channel to our new loadgroup.  Make sure to
@@ -996,7 +996,7 @@ nsJSChannel::OnStopRequest(nsIRequest* a
 {
     NS_ENSURE_TRUE(aRequest == mStreamChannel, NS_ERROR_UNEXPECTED);
 
-    nsCOMPtr<nsIStreamListener> listener = mListener;
+    nsIStreamListener* listener = mListener;
 
     CleanupStrongRefs();
 
@@ -1007,8 +1007,8 @@ nsJSChannel::OnStopRequest(nsIRequest* a
     
     nsresult rv = listener->OnStopRequest(this, aContext, aStatus);
 
-    nsCOMPtr<nsILoadGroup> loadGroup;
-    mStreamChannel->GetLoadGroup(getter_AddRefs(loadGroup));
+    nsILoadGroup* loadGroup = nsnull;
+    mStreamChannel->GetLoadGroup(&loadGroup);
     if (loadGroup) {
         loadGroup->RemoveRequest(this, nsnull, mStatus);
     }
diff --git a/extensions/cookie/nsCookiePermission.cpp b/extensions/cookie/nsCookiePermission.cpp
--- a/extensions/cookie/nsCookiePermission.cpp
+++ b/extensions/cookie/nsCookiePermission.cpp
@@ -349,9 +349,9 @@ nsCookiePermission::CanSetCookie(nsIURI 
       if (NS_FAILED(rv)) return rv;
 
       // try to get a nsIDOMWindow from the channel...
-      nsCOMPtr<nsIDOMWindow> parent;
+      nsIDOMWindow* parent = nsnull;
       if (aChannel)
-        NS_QueryNotificationCallbacks(aChannel, parent);
+        NS_QueryNotificationCallbacks(aChannel, &parent);
 
       // get some useful information to present to the user:
       // whether a previous cookie already exists, and how many cookies this host
diff --git a/extensions/gnomevfs/nsGnomeVFSProtocolHandler.cpp b/extensions/gnomevfs/nsGnomeVFSProtocolHandler.cpp
--- a/extensions/gnomevfs/nsGnomeVFSProtocolHandler.cpp
+++ b/extensions/gnomevfs/nsGnomeVFSProtocolHandler.cpp
@@ -162,8 +162,8 @@ ProxiedAuthCallback(gconstpointer in,
   if (!channel)
     return;
 
-  nsCOMPtr<nsIAuthPrompt> prompt;
-  NS_QueryNotificationCallbacks(channel, prompt);
+  nsIAuthPrompt* prompt = nsnull;
+  NS_QueryNotificationCallbacks(channel, &prompt);
 
   // If no auth prompt, then give up.  We could failover to using the
   // WindowWatcher service, but that might defeat a consumer's purposeful
diff --git a/intl/unicharutil/src/nsCategoryImp.cpp b/intl/unicharutil/src/nsCategoryImp.cpp
--- a/intl/unicharutil/src/nsCategoryImp.cpp
+++ b/intl/unicharutil/src/nsCategoryImp.cpp
@@ -43,13 +43,17 @@
 #include "cattable.h"
 
 // XXXbsmedberg this is bad, must go
-static nsCategoryImp gCategoryImp;
+static nsCategoryImp *gCategoryImp;
 
 NS_IMPL_THREADSAFE_QUERY_INTERFACE1(nsCategoryImp, nsIUGenCategory)
 
 nsCategoryImp* nsCategoryImp::GetInstance()
 {
-  return &gCategoryImp;
+  if (!gCategoryImp) {
+    gCategoryImp = new nsCategoryImp;
+    NS_RootUntilShutdown(gCategoryImp);
+  }
+  return gCategoryImp;
 }
 
 nsIUGenCategory::nsUGenCategory nsCategoryImp::Get(PRUint32 aChar)
diff --git a/layout/style/nsCSSLoader.cpp b/layout/style/nsCSSLoader.cpp
--- a/layout/style/nsCSSLoader.cpp
+++ b/layout/style/nsCSSLoader.cpp
@@ -1566,7 +1566,7 @@ CSSLoaderImpl::SheetComplete(SheetLoadDa
     while (iter.HasMore()) {
       obs = iter.GetNext();
       LOG(("  Notifying global observer 0x%x for data 0x%s.  wasAlternate: %d",
-           obs.get(), data, data->mWasAlternate));
+           (nsICSSLoaderObserver*) obs, data, data->mWasAlternate));
       obs->StyleSheetLoaded(data->mSheet, data->mWasAlternate, aStatus);
     }
   }
@@ -2072,7 +2072,7 @@ CSSLoaderImpl::PostLoadEvent(nsIURI* aUR
   NS_PRECONDITION(aSheet, "Must have sheet");
   NS_PRECONDITION(aObserver, "Must have observer");
 
-  nsRefPtr<SheetLoadData> evt =
+  SheetLoadData* evt =
     new SheetLoadData(this, EmptyString(), // title doesn't matter here
                       aURI,
                       aSheet,
diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -4061,7 +4061,7 @@ PRBool CSSParserImpl::ParseCounter(nsres
     return PR_FALSE;
   }
 
-  nsRefPtr<nsCSSValue::Array> val =
+  nsCSSValue::Array* val =
     nsCSSValue::Array::Create(unit == eCSSUnit_Counter ? 2 : 3);
   if (!val) {
     aErrorCode = NS_ERROR_OUT_OF_MEMORY;
@@ -5941,7 +5941,7 @@ PRBool CSSParserImpl::ParseCursor(nsresu
       return PR_TRUE;
     } 
     // We have a URL, so make a value array with three values.
-    nsRefPtr<nsCSSValue::Array> val = nsCSSValue::Array::Create(3);
+    nsCSSValue::Array* val = nsCSSValue::Array::Create(3);
     if (!val) {
       aErrorCode = NS_ERROR_OUT_OF_MEMORY;
       break;
diff --git a/layout/xul/base/src/nsListBoxBodyFrame.cpp b/layout/xul/base/src/nsListBoxBodyFrame.cpp
--- a/layout/xul/base/src/nsListBoxBodyFrame.cpp
+++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp
@@ -880,7 +880,7 @@ nsresult
 nsresult
 nsListBoxBodyFrame::InternalPositionChanged(PRBool aUp, PRInt32 aDelta)
 {
-  nsRefPtr<nsPositionChangedEvent> ev =
+  nsPositionChangedEvent* ev =
     new nsPositionChangedEvent(this, aUp, aDelta);
   nsresult rv = NS_DispatchToCurrentThread(ev);
   if (NS_SUCCEEDED(rv)) {
diff --git a/netwerk/base/src/nsBaseChannel.cpp b/netwerk/base/src/nsBaseChannel.cpp
--- a/netwerk/base/src/nsBaseChannel.cpp
+++ b/netwerk/base/src/nsBaseChannel.cpp
@@ -124,8 +124,8 @@ nsBaseChannel::Redirect(nsIChannel *newC
   if (!(redirectFlags & nsIChannelEventSink::REDIRECT_INTERNAL)) {
     nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface();
     if (httpChannel) {
-      nsCOMPtr<nsIHttpEventSink> httpEventSink;
-      GetCallback(httpEventSink);
+      nsIHttpEventSink* httpEventSink = nsnull;
+      GetCallback(&httpEventSink);
       if (httpEventSink) {
         rv = httpEventSink->OnRedirect(httpChannel, newChannel);
         if (NS_FAILED(rv))
@@ -134,9 +134,9 @@ nsBaseChannel::Redirect(nsIChannel *newC
     }
   }
 
-  nsCOMPtr<nsIChannelEventSink> channelEventSink;
+  nsIChannelEventSink* channelEventSink = nsnull;
   // Give our consumer a chance to observe/block this redirect.
-  GetCallback(channelEventSink);
+  GetCallback(&channelEventSink);
   if (channelEventSink) {
     rv = channelEventSink->OnChannelRedirect(this, newChannel, redirectFlags);
     if (NS_FAILED(rv))
diff --git a/netwerk/test/TestPageLoad.cpp b/netwerk/test/TestPageLoad.cpp
--- a/netwerk/test/TestPageLoad.cpp
+++ b/netwerk/test/TestPageLoad.cpp
@@ -65,8 +65,8 @@ nsresult auxLoad(char *uriBuf);
 
 static nsCString globalStream;
 //static char urlBuf[256];
-static nsCOMPtr<nsIURI> baseURI;
-static nsCOMPtr<nsISupportsArray> uriList;
+static nsIURI* baseURI;
+static nsISupportsArray* uriList;
 
 //Temp, should remove:
 static int numStart=0;
@@ -374,7 +374,7 @@ int main(int argc, char **argv)
         nsCOMPtr<nsIStreamListener> listener = new MyListener();
         nsCOMPtr<nsIInterfaceRequestor> callbacks = new MyNotifications();
 
-        rv = NS_NewURI(getter_AddRefs(baseURI), argv[1]);
+        rv = NS_NewURI(&baseURI, argv[1]);
         RETURN_IF_FAILED(rv, "NS_NewURI");
 
         rv = NS_NewChannel(getter_AddRefs(chan), baseURI, nsnull, nsnull, callbacks);
diff --git a/toolkit/components/places/src/nsMaybeWeakPtr.cpp b/toolkit/components/places/src/nsMaybeWeakPtr.cpp
--- a/toolkit/components/places/src/nsMaybeWeakPtr.cpp
+++ b/toolkit/components/places/src/nsMaybeWeakPtr.cpp
@@ -50,7 +50,7 @@ nsMaybeWeakPtr_base::GetValueAs(const ns
     }
   }
 
-  nsCOMPtr<nsIWeakReference> weakRef = do_QueryInterface(mPtr);
+  nsIWeakReference* weakRef = do_QueryInterface(mPtr);
   if (weakRef) {
     rv = weakRef->QueryReferent(iid, &ref);
     if (NS_SUCCEEDED(rv)) {
@@ -66,11 +66,9 @@ nsMaybeWeakPtrArray_base::AppendWeakElem
                                                 nsISupports *aElement,
                                                 PRBool aOwnsWeak)
 {
-  nsCOMPtr<nsISupports> ref;
+  nsISupports* ref;
   if (aOwnsWeak) {
-    nsCOMPtr<nsIWeakReference> weakRef;
-    weakRef = do_GetWeakReference(aElement);
-    reinterpret_cast<nsCOMPtr<nsISupports>*>(&weakRef)->swap(ref);
+    ref = do_GetWeakReference(aElement);
   } else {
     ref = aElement;
   }
@@ -98,11 +96,11 @@ nsMaybeWeakPtrArray_base::RemoveWeakElem
 
   // Don't use do_GetWeakReference; it should only be called if we know
   // the object supports weak references.
-  nsCOMPtr<nsISupportsWeakReference> supWeakRef = do_QueryInterface(aElement);
+  nsISupportsWeakReference* supWeakRef = do_QueryInterface(aElement);
   NS_ENSURE_TRUE(supWeakRef, NS_ERROR_INVALID_ARG);
 
-  nsCOMPtr<nsIWeakReference> weakRef;
-  nsresult rv = supWeakRef->GetWeakReference(getter_AddRefs(weakRef));
+  nsIWeakReference* weakRef;
+  nsresult rv = supWeakRef->GetWeakReference(&weakRef);
   NS_ENSURE_SUCCESS(rv, rv);
 
   index = array->IndexOf((nsISupports*) weakRef);
diff --git a/uriloader/prefetch/nsOfflineCacheUpdate.cpp b/uriloader/prefetch/nsOfflineCacheUpdate.cpp
--- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp
@@ -1022,7 +1022,7 @@ nsOfflineCacheUpdate::AddOwnedItems(cons
     for (PRUint32 i = 0; i < count; i++) {
         nsCOMPtr<nsIURI> uri;
         if (NS_SUCCEEDED(NS_NewURI(getter_AddRefs(uri), keys[i]))) {
-            nsRefPtr<nsOfflineCacheUpdateItem> item =
+            nsOfflineCacheUpdateItem* item =
                 new nsOfflineCacheUpdateItem(this, uri, mDocumentURI,
                                              mClientID);
             if (!item) return NS_ERROR_OUT_OF_MEMORY;
@@ -1314,7 +1314,7 @@ nsOfflineCacheUpdate::AddURI(nsIURI *aUR
         }
     }
 
-    nsRefPtr<nsOfflineCacheUpdateItem> item =
+    nsOfflineCacheUpdateItem* item =
         new nsOfflineCacheUpdateItem(this, aURI, mDocumentURI, mClientID);
     if (!item) return NS_ERROR_OUT_OF_MEMORY;
 
diff --git a/uriloader/prefetch/nsOfflineCacheUpdate.h b/uriloader/prefetch/nsOfflineCacheUpdate.h
--- a/uriloader/prefetch/nsOfflineCacheUpdate.h
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.h
@@ -229,7 +229,7 @@ private:
 
     /* Items being updated */
     PRInt32 mCurrentItem;
-    nsTArray<nsRefPtr<nsOfflineCacheUpdateItem> > mItems;
+    nsTArray<nsOfflineCacheUpdateItem*, GCAllocator> mItems;
 
     /* Clients watching this update for changes */
     nsCOMArray<nsIWeakReference> mWeakObservers;
diff --git a/xpcom/glue/nsCategoryCache.h b/xpcom/glue/nsCategoryCache.h
--- a/xpcom/glue/nsCategoryCache.h
+++ b/xpcom/glue/nsCategoryCache.h
@@ -124,14 +124,14 @@ nsCategoryCache<T>::nsCategoryCache(cons
 
 template<class T>
 void nsCategoryCache<T>::EntryAdded(const nsCString& aValue) {
-  nsCOMPtr<T> catEntry = do_GetService(aValue.get());
+  T* catEntry = do_GetService(aValue.get());
   if (catEntry)
     mEntries.AppendObject(catEntry);
 }
 
 template<class T>
 void nsCategoryCache<T>::EntryRemoved(const nsCString& aValue) {
-  nsCOMPtr<T> catEntry = do_GetService(aValue.get());
+  T* catEntry = do_GetService(aValue.get());
   if (catEntry)
     mEntries.RemoveObject(catEntry);
 }