From 7aa9391f403aca166a120a2e15723f9eba7608f8 Mon Sep 17 00:00:00 2001 From: "timeless%mozdev.org" Date: Fri, 5 Nov 2004 15:13:32 +0000 Subject: [PATCH] Bug 258642 Unused functions [PRUni]charPtrArrayTo[C]StringArray & [C]StringArrayTo[PRUni]charPtrArray patch by mikael@parknert.se r=neil sr=bienvenu --- mailnews/addrbook/src/Makefile.in | 1 - mailnews/addrbook/src/nsAbBSDirectory.cpp | 1 - mailnews/addrbook/src/nsAbDirectoryQuery.cpp | 28 ++++++--- mailnews/addrbook/src/nsAbLDAPDirectory.cpp | 10 +--- mailnews/addrbook/src/nsAbMDBDirectory.cpp | 10 +--- .../addrbook/src/nsAbOutlookDirectory.cpp | 9 +-- mailnews/addrbook/src/nsAbRDFDataSource.cpp | 1 - mailnews/addrbook/src/nsAbUtils.cpp | 0 mailnews/addrbook/src/nsAbUtils.h | 58 ------------------- mailnews/addrbook/src/nsAbWinHelper.cpp | 1 - mailnews/addrbook/src/nsMapiAddressBook.cpp | 1 - mailnews/addrbook/src/nsWabAddressBook.cpp | 1 - 12 files changed, 25 insertions(+), 96 deletions(-) delete mode 100644 mailnews/addrbook/src/nsAbUtils.cpp diff --git a/mailnews/addrbook/src/Makefile.in b/mailnews/addrbook/src/Makefile.in index ee04d813a1b..7c96d2c89a0 100644 --- a/mailnews/addrbook/src/Makefile.in +++ b/mailnews/addrbook/src/Makefile.in @@ -92,7 +92,6 @@ CPPSRCS = \ nsAddbookUrl.cpp \ nsAbDirFactoryService.cpp \ nsAbMDBDirFactory.cpp \ - nsAbUtils.cpp \ nsAbDirectoryQuery.cpp \ nsAbDirectoryQueryProxy.cpp \ nsAbDirSearchListener.cpp \ diff --git a/mailnews/addrbook/src/nsAbBSDirectory.cpp b/mailnews/addrbook/src/nsAbBSDirectory.cpp index ec3b679e782..0c5eea5fdb0 100644 --- a/mailnews/addrbook/src/nsAbBSDirectory.cpp +++ b/mailnews/addrbook/src/nsAbBSDirectory.cpp @@ -40,7 +40,6 @@ #include "nsIPrefService.h" #include "nsAbBSDirectory.h" -#include "nsAbUtils.h" #include "nsRDFCID.h" #include "nsIRDFService.h" diff --git a/mailnews/addrbook/src/nsAbDirectoryQuery.cpp b/mailnews/addrbook/src/nsAbDirectoryQuery.cpp index 8cd4eb76284..267992631c7 100644 --- a/mailnews/addrbook/src/nsAbDirectoryQuery.cpp +++ b/mailnews/addrbook/src/nsAbDirectoryQuery.cpp @@ -176,12 +176,14 @@ NS_IMETHODIMP nsAbDirectoryQueryArguments::SetQuerySubDirectories(PRBool aQueryS NS_IMETHODIMP nsAbDirectoryQueryArguments::SetReturnProperties(PRUint32 returnPropertiesSize, const char** returnPropertiesArray) { - nsresult rv; - rv = CharPtrArrayToCStringArray::Convert(mReturnProperties, - returnPropertiesSize, - returnPropertiesArray); + NS_ENSURE_ARG_POINTER(returnPropertiesArray); - return rv; + mReturnProperties.Clear(); + + for (PRUint32 i = 0; i < returnPropertiesSize; i++) + mReturnProperties.AppendCString(nsDependentCString(returnPropertiesArray[i])); + + return NS_OK; } /* void getReturnProperties (out unsigned long returnPropertiesSize, @@ -189,11 +191,19 @@ NS_IMETHODIMP nsAbDirectoryQueryArguments::SetReturnProperties(PRUint32 returnPr NS_IMETHODIMP nsAbDirectoryQueryArguments::GetReturnProperties(PRUint32* returnPropertiesSize, char*** returnPropertiesArray) { - nsresult rv; - rv = CStringArrayToCharPtrArray::Convert (mReturnProperties, - returnPropertiesSize, returnPropertiesArray); + NS_ENSURE_ARG_POINTER(returnPropertiesSize); + NS_ENSURE_ARG_POINTER(returnPropertiesArray); - return rv; + PRUint32 size = mReturnProperties.Count(); + *returnPropertiesSize = size; + *returnPropertiesArray = NS_STATIC_CAST(char**, nsMemory::Alloc (sizeof (char* ) * size)); + if (!(*returnPropertiesArray)) + return NS_ERROR_OUT_OF_MEMORY; + + for (PRUint32 i = 0; i < size; i++) + (*returnPropertiesArray)[i] = ToNewCString(*mReturnProperties[i]); + + return NS_OK; } NS_IMPL_THREADSAFE_ISUPPORTS1(nsAbDirectoryQueryPropertyValue, nsIAbDirectoryQueryPropertyValue) diff --git a/mailnews/addrbook/src/nsAbLDAPDirectory.cpp b/mailnews/addrbook/src/nsAbLDAPDirectory.cpp index d4dc3b10ca5..9d86b94049c 100644 --- a/mailnews/addrbook/src/nsAbLDAPDirectory.cpp +++ b/mailnews/addrbook/src/nsAbLDAPDirectory.cpp @@ -40,7 +40,6 @@ #include "nsAbLDAPDirectory.h" #include "nsAbLDAPProperties.h" -#include "nsAbUtils.h" #include "nsAbQueryStringToExpression.h" @@ -362,13 +361,8 @@ NS_IMETHODIMP nsAbLDAPDirectory::StartSearch () // Set the return properties to // return nsIAbCard interfaces - nsCStringArray properties; - properties.AppendCString (nsCAutoString ("card:nsIAbCard")); - CharPtrArrayGuard returnProperties (PR_FALSE); - rv = CStringArrayToCharPtrArray::Convert (properties,returnProperties.GetSizeAddr(), - returnProperties.GetArrayAddr(), PR_FALSE); - NS_ENSURE_SUCCESS(rv, rv); - rv = arguments->SetReturnProperties (returnProperties.GetSize(), returnProperties.GetArray()); + const char *arr = "card:nsIAbCard"; + rv = arguments->SetReturnProperties (1, &arr); NS_ENSURE_SUCCESS(rv, rv); rv = arguments->SetQuerySubDirectories (PR_TRUE); diff --git a/mailnews/addrbook/src/nsAbMDBDirectory.cpp b/mailnews/addrbook/src/nsAbMDBDirectory.cpp index be12600a6a0..41d11c09626 100644 --- a/mailnews/addrbook/src/nsAbMDBDirectory.cpp +++ b/mailnews/addrbook/src/nsAbMDBDirectory.cpp @@ -54,7 +54,6 @@ #include "nsAbDirectoryQuery.h" #include "nsIAbDirectoryQueryProxy.h" #include "nsAbQueryStringToExpression.h" -#include "nsAbUtils.h" #include "nsArrayEnumerator.h" #include "nsAbMDBCardProperty.h" @@ -909,13 +908,8 @@ NS_IMETHODIMP nsAbMDBDirectory::StartSearch() // Set the return properties to // return nsIAbCard interfaces - nsCStringArray properties; - properties.AppendCString(nsCAutoString("card:nsIAbCard")); - CharPtrArrayGuard returnProperties(PR_FALSE); - rv = CStringArrayToCharPtrArray::Convert(properties,returnProperties.GetSizeAddr(), - returnProperties.GetArrayAddr(), PR_FALSE); - NS_ENSURE_SUCCESS(rv, rv); - rv = arguments->SetReturnProperties(returnProperties.GetSize(), returnProperties.GetArray()); + const char *arr = "card:nsIAbCard"; + rv = arguments->SetReturnProperties(1, &arr); NS_ENSURE_SUCCESS(rv, rv); // don't search the subdirectories diff --git a/mailnews/addrbook/src/nsAbOutlookDirectory.cpp b/mailnews/addrbook/src/nsAbOutlookDirectory.cpp index cbc9593c70a..a86e65420e9 100644 --- a/mailnews/addrbook/src/nsAbOutlookDirectory.cpp +++ b/mailnews/addrbook/src/nsAbOutlookDirectory.cpp @@ -995,14 +995,9 @@ NS_IMETHODIMP nsAbOutlookDirectory::StartSearch(void) NS_ENSURE_SUCCESS(retCode, retCode) ; retCode = arguments->SetExpression(expression) ; NS_ENSURE_SUCCESS(retCode, retCode) ; - nsCStringArray properties ; - CharPtrArrayGuard returnProperties(PR_FALSE) ; - properties.AppendCString(nsCAutoString("card:nsIAbCard")) ; - retCode = CStringArrayToCharPtrArray::Convert(properties, returnProperties.GetSizeAddr(), - returnProperties.GetArrayAddr(), PR_FALSE) ; - NS_ENSURE_SUCCESS(retCode, retCode) ; - retCode = arguments->SetReturnProperties(returnProperties.GetSize(), returnProperties.GetArray()) ; + const char *arr = "card:nsIAbCard"; + retCode = arguments->SetReturnProperties(1, &arr); NS_ENSURE_SUCCESS(retCode, retCode) ; retCode = arguments->SetQuerySubDirectories(PR_TRUE) ; NS_ENSURE_SUCCESS(retCode, retCode) ; diff --git a/mailnews/addrbook/src/nsAbRDFDataSource.cpp b/mailnews/addrbook/src/nsAbRDFDataSource.cpp index 869a9fc939b..0e8207fedb4 100644 --- a/mailnews/addrbook/src/nsAbRDFDataSource.cpp +++ b/mailnews/addrbook/src/nsAbRDFDataSource.cpp @@ -41,7 +41,6 @@ #include "nsIAbDirectory.h" #include "nsIAddrBookSession.h" #include "nsIAbCard.h" -#include "nsAbUtils.h" #include "rdf.h" #include "nsIRDFService.h" diff --git a/mailnews/addrbook/src/nsAbUtils.cpp b/mailnews/addrbook/src/nsAbUtils.cpp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/mailnews/addrbook/src/nsAbUtils.h b/mailnews/addrbook/src/nsAbUtils.h index d17ec0a0f57..b62254b8d4d 100644 --- a/mailnews/addrbook/src/nsAbUtils.h +++ b/mailnews/addrbook/src/nsAbUtils.h @@ -105,40 +105,10 @@ private: else { nsMemory::Free(mArray); - mArray=nsnull; } } }; - -/* - * Helper class to convert an nsCStringArray - * to an array of char* - * By default strings will be copied, unless - * the copyElements parameter is set to PR_FALSE. - */ -class CStringArrayToCharPtrArray -{ -public: - static nsresult Convert (nsCStringArray& array, - PRUint32* returnPropertiesSize, - char*** returnPropertiesArray, - PRBool copyElements = PR_TRUE); -}; - -/* - * Helper class to convert an array of char* - * to an nsCStringArray - */ -class CharPtrArrayToCStringArray -{ -public: - static nsresult Convert (nsCStringArray& array, - PRUint32 returnPropertiesSize, - const char** returnPropertiesArray); -}; - - /* * Wrapper class to automatically free an array of * PRUnichar* when class goes out of scope @@ -199,36 +169,8 @@ private: else { nsMemory::Free(mArray); - mArray=nsnull; } } }; -/* - * Helper class to convert an nsStringArray - * to an array of PRUnichar* - * By default strings will be copied, unless - * the copyElements parameter is set to PR_FALSE. - */ -class StringArrayToPRUnicharPtrArray -{ -public: - static nsresult Convert (nsStringArray& array, - PRUint32* returnPropertiesSize, - PRUnichar*** returnPropertiesArray, - PRBool copyElements = PR_TRUE); -}; - -/* - * Helper class to convert an array of PRUnichar* - * to an nsStringArray - */ -class PRUnicharPtrArrayToStringArray -{ -public: - static nsresult Convert (nsStringArray& returnPropertiesArray, - PRUint32 returnPropertiesSize, - const PRUnichar** array); -}; - #endif /* nsAbUtils_h__ */ diff --git a/mailnews/addrbook/src/nsAbWinHelper.cpp b/mailnews/addrbook/src/nsAbWinHelper.cpp index 93bbe17a0dc..a193e817598 100644 --- a/mailnews/addrbook/src/nsAbWinHelper.cpp +++ b/mailnews/addrbook/src/nsAbWinHelper.cpp @@ -44,7 +44,6 @@ #define USES_IID_IDistList #include "nsAbWinHelper.h" -#include "nsAbUtils.h" #include "nsMapiAddressBook.h" #include "nsWabAddressBook.h" #include "nsCRT.h" diff --git a/mailnews/addrbook/src/nsMapiAddressBook.cpp b/mailnews/addrbook/src/nsMapiAddressBook.cpp index 49d42cccde8..bc6033212c7 100644 --- a/mailnews/addrbook/src/nsMapiAddressBook.cpp +++ b/mailnews/addrbook/src/nsMapiAddressBook.cpp @@ -36,7 +36,6 @@ * * ***** END LICENSE BLOCK ***** */ #include "nsMapiAddressBook.h" -#include "nsAbUtils.h" #include "nsAutoLock.h" #include "prlog.h" diff --git a/mailnews/addrbook/src/nsWabAddressBook.cpp b/mailnews/addrbook/src/nsWabAddressBook.cpp index 3937163fb80..b0a0909a116 100644 --- a/mailnews/addrbook/src/nsWabAddressBook.cpp +++ b/mailnews/addrbook/src/nsWabAddressBook.cpp @@ -36,7 +36,6 @@ * * ***** END LICENSE BLOCK ***** */ #include "nsWabAddressBook.h" -#include "nsAbUtils.h" #include "nsAutoLock.h" #include "prlog.h"