Bug 1410703 - Port bug 1410518 to mailnews: nsIRDFDataSource::GetURI() uses ACString now. rs=bustage-fix
authorJorg K <jorgk@jorgk.com>
Sun, 22 Oct 2017 12:16:05 +0200
changeset 29234 c2981c178f3ebf42e6bb2c3358b605e289270297
parent 29233 af9f898b3480bf9354d5d942eb96381271456c72
child 29235 9760a85ceffe37a3c77225e5a9242da98d9ae6b9
push id2068
push userclokep@gmail.com
push dateMon, 13 Nov 2017 19:02:14 +0000
treeherdercomm-beta@9c7e7ce8672b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage-fix
bugs1410703, 1410518
Bug 1410703 - Port bug 1410518 to mailnews: nsIRDFDataSource::GetURI() uses ACString now. rs=bustage-fix
mailnews/base/src/nsMsgFolderDataSource.cpp
mailnews/base/src/nsMsgFolderDataSource.h
mailnews/base/src/nsMsgRDFDataSource.cpp
mailnews/base/src/nsSubscribeDataSource.cpp
--- a/mailnews/base/src/nsMsgFolderDataSource.cpp
+++ b/mailnews/base/src/nsMsgFolderDataSource.cpp
@@ -296,22 +296,20 @@ nsresult nsMsgFolderDataSource::CreateAr
 }
 
 NS_IMPL_ADDREF_INHERITED(nsMsgFolderDataSource, nsMsgRDFDataSource)
 NS_IMPL_RELEASE_INHERITED(nsMsgFolderDataSource, nsMsgRDFDataSource)
 
 NS_IMPL_QUERY_INTERFACE_INHERITED(nsMsgFolderDataSource, nsMsgRDFDataSource, nsIFolderListener)
 
  // nsIRDFDataSource methods
-NS_IMETHODIMP nsMsgFolderDataSource::GetURI(char* *uri)
+NS_IMETHODIMP nsMsgFolderDataSource::GetURI(nsACString& uri)
 {
-  if ((*uri = strdup("rdf:mailnewsfolders")) == nullptr)
-    return NS_ERROR_OUT_OF_MEMORY;
-  else
-    return NS_OK;
+  uri.AssignLiteral("rdf:mailnewsfolders");
+  return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgFolderDataSource::GetSource(nsIRDFResource* property,
                                                nsIRDFNode* target,
                                                bool tv,
                                                nsIRDFResource** source /* out */)
 {
   NS_ASSERTION(false, "not implemented");
@@ -2136,22 +2134,21 @@ void nsMsgFlatFolderDataSource::EnsureFo
   {
     nsCOMPtr<nsIMsgFolder> curFolder = do_QueryElementAt(allFolders, i);
     if (WantsThisFolder(curFolder))
       m_folders.AppendObject(curFolder);
   }
 }
 
 
-NS_IMETHODIMP nsMsgFlatFolderDataSource::GetURI(char* *aUri)
+NS_IMETHODIMP nsMsgFlatFolderDataSource::GetURI(nsACString& aUri)
 {
-  nsAutoCString uri("rdf:");
-  uri.Append(m_dsName);
-  return (*aUri = ToNewCString(uri))
-    ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
+  aUri.AssignLiteral("rdf:");
+  aUri.Append(m_dsName);
+  return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgFlatFolderDataSource::HasAssertion(nsIRDFResource* source,
                             nsIRDFResource* property,
                             nsIRDFNode* target,
                             bool tv,
                             bool* hasAssertion)
 {
--- a/mailnews/base/src/nsMsgFolderDataSource.h
+++ b/mailnews/base/src/nsMsgFolderDataSource.h
@@ -36,17 +36,17 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIFOLDERLISTENER
 
   nsMsgFolderDataSource(void);
   virtual nsresult Init() override;
   virtual void Cleanup() override;
 
   // nsIRDFDataSource methods
-  NS_IMETHOD GetURI(char* *uri) override;
+  NS_IMETHOD GetURI(nsACString& uri) override;
 
   NS_IMETHOD GetSource(nsIRDFResource* property,
                        nsIRDFNode* target,
                        bool tv,
                        nsIRDFResource** source /* out */) override;
 
   NS_IMETHOD GetTarget(nsIRDFResource* source,
                        nsIRDFResource* property,
@@ -273,17 +273,17 @@ class nsMsgFlatFolderDataSource : public
 {
 public:
   // constructor could take a filter to filter out folders.
   nsMsgFlatFolderDataSource();
   virtual ~nsMsgFlatFolderDataSource();
   virtual nsresult Init() override;
   virtual void Cleanup() override;
 
-  NS_IMETHOD GetURI(char* *uri) override;
+  NS_IMETHOD GetURI(nsACString& uri) override;
   NS_IMETHOD GetTargets(nsIRDFResource* source,
                         nsIRDFResource* property,
                         bool tv,
                         nsISimpleEnumerator** targets) override;
   NS_IMETHOD GetTarget(nsIRDFResource* source,
                        nsIRDFResource* property,
                        bool tv,
                        nsIRDFNode** target) override;
--- a/mailnews/base/src/nsMsgRDFDataSource.cpp
+++ b/mailnews/base/src/nsMsgRDFDataSource.cpp
@@ -83,17 +83,17 @@ NS_INTERFACE_MAP_BEGIN(nsMsgRDFDataSourc
   NS_INTERFACE_MAP_ENTRY(nsIMsgRDFDataSource)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIRDFDataSource)
   NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsMsgRDFDataSource)
 NS_INTERFACE_MAP_END
 
 /* readonly attribute string URI; */
 NS_IMETHODIMP
-nsMsgRDFDataSource::GetURI(char * *aURI)
+nsMsgRDFDataSource::GetURI(nsACString& aURI)
 {
     NS_NOTREACHED("should be implemented by a subclass");
     return NS_ERROR_UNEXPECTED;
 }
 
 
 /* nsIRDFResource GetSource (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
 NS_IMETHODIMP
--- a/mailnews/base/src/nsSubscribeDataSource.cpp
+++ b/mailnews/base/src/nsSubscribeDataSource.cpp
@@ -71,22 +71,20 @@ nsSubscribeDataSource::Init()
     NS_ENSURE_SUCCESS(rv,rv);
 
     rv = mRDFService->GetLiteral(u"false", getter_AddRefs(kFalseLiteral));
     NS_ENSURE_SUCCESS(rv,rv);
 	return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSubscribeDataSource::GetURI(char * *aURI)
+nsSubscribeDataSource::GetURI(nsACString& aURI)
 {
-  if ((*aURI = strdup("rdf:subscribe")) == nullptr)
-    return NS_ERROR_OUT_OF_MEMORY;
-  else
-    return NS_OK;
+  aURI.AssignLiteral("rdf:subscribe");
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSubscribeDataSource::GetSource(nsIRDFResource *property, nsIRDFNode *target, bool tv, nsIRDFResource **source)
 {
     NS_PRECONDITION(property != nullptr, "null ptr");
     if (! property)
         return NS_ERROR_NULL_POINTER;