diff --git a/intl/uconv/idl/nsICharsetConverterManager2.idl b/intl/uconv/idl/nsICharsetConverterManager2.idl index 64d1639e6ea..814be228a43 100644 --- a/intl/uconv/idl/nsICharsetConverterManager2.idl +++ b/intl/uconv/idl/nsICharsetConverterManager2.idl @@ -45,6 +45,11 @@ * If these problems will hurt us, we'll switch to nsICharacterSet. The * implementation of this interface is ment to be quite flexible. * + * I provide here some nonscriptable "friendly methods". They accept nsString + * as params and assign the result to them, freeing the received memory result. + * These methods are prone to optimisation, in order to elliminate any + * allocation when it not strictly necessary. + * * @created 21/Feb/2000 * @author Catalin Rotaru [CATA] */ @@ -88,6 +93,12 @@ interface nsICharsetConverterManager2 : nsISupports */ wstring GetCharsetTitle([const] in nsIAtom charset); + /** + * Friendlier but non scriptable version. + */ + [noscript] void GetCharsetTitle2([const] in nsIAtom charset, + in nsStringPtr str); + /** * Get some data about the given charset. */ diff --git a/intl/uconv/src/nsCharsetConverterManager.cpp b/intl/uconv/src/nsCharsetConverterManager.cpp index 213989e03b5..8fdace744a7 100644 --- a/intl/uconv/src/nsCharsetConverterManager.cpp +++ b/intl/uconv/src/nsCharsetConverterManager.cpp @@ -66,6 +66,8 @@ public: /** * The actual implementation of the nsICharsetConverterManager interface. * + * XXX optimise the memory allocations in "scriptable" and "friendly" methods + * * @created 15/Nov/1999 * @author Catalin Rotaru [CATA] */ @@ -160,6 +162,7 @@ public: NS_IMETHOD GetCharsetAtom(const PRUnichar * aCharset, nsIAtom ** aResult); NS_IMETHOD GetCharsetTitle(const nsIAtom * aCharset, PRUnichar ** aResult); + NS_IMETHOD GetCharsetTitle2(const nsIAtom * aCharset, nsString * aResult); NS_IMETHOD GetCharsetData(const nsIAtom * aCharset, const PRUnichar * aProp, PRUnichar ** aResult); NS_IMETHOD GetCharsetData2(const nsIAtom * aCharset, const PRUnichar * aProp, @@ -1054,6 +1057,23 @@ NS_IMETHODIMP nsCharsetConverterManager::GetCharsetTitle( return res; } +NS_IMETHODIMP nsCharsetConverterManager::GetCharsetTitle2( + const nsIAtom * aCharset, + nsString * aResult) +{ + if (aResult == NULL) return NS_ERROR_NULL_POINTER; + + nsresult res = NS_OK; + + PRUnichar * title; + res = GetCharsetTitle(aCharset, &title); + if (NS_FAILED(res)) return res; + + aResult->Assign(title); + PR_Free(title); + return res; +} + NS_IMETHODIMP nsCharsetConverterManager::GetCharsetData( const nsIAtom * aCharset, const PRUnichar * aProp,