*aCount = 0; *aResult = nsnull;  PRInt32     numDocs = mPrt->mPrintDocList->Count(); PRUnichar** array   = (PRUnichar**) nsMemory::Alloc(numDocs * sizeof(PRUnichar*)); if (!array) return NS_ERROR_OUT_OF_MEMORY;  for (PRInt32 i=0;i<numDocs;i++) { PrintObject* po = (PrintObject*)mPrt->mPrintDocList->ElementAt(i); NS_ASSERTION(po, "PrintObject can't be null!"); PRUnichar * docTitleStr; PRUnichar * docURLStr; GetWebShellTitleAndURL(po->mWebShell, &docTitleStr, &docURLStr);   if (!docTitleStr || !*docTitleStr) { if (docURLStr && nsCRT::strlen(docURLStr) > 0) { nsMemory::Free(docTitleStr); docTitleStr = docURLStr; } else { nsMemory::Free(docURLStr); } docURLStr = nsnull; if (!docTitleStr || !*docTitleStr) { CleanupDocTitleArray(array, i); return NS_ERROR_OUT_OF_MEMORY; } } array[i] = docTitleStr; if (docURLStr) nsMemory::Free(docURLStr); } *aCount  = numDocs; *aResult = array;  return NS_OK;
return mPrintEngine->EnumerateDocumentNames(aCount, aResult); #else return NS_ERROR_FAILURE; #endif
DocumentViewerImpl::EnumerateDocumentNames(PRUint32* aCount,                                           PRUnichar*** aResult){  NS_ENSURE_ARG(aCount);  NS_ENSURE_ARG_POINTER(aResult);  *aCount = 0;  *aResult = nsnull;  PRInt32     numDocs = mPrt->mPrintDocList->Count();  PRUnichar** array   = (PRUnichar**) nsMemory::Alloc(numDocs * sizeof(PRUnichar*));  if (!array)    return NS_ERROR_OUT_OF_MEMORY;  for (PRInt32 i=0;i<numDocs;i++) {    PrintObject* po = (PrintObject*)mPrt->mPrintDocList->ElementAt(i);    NS_ASSERTION(po, "PrintObject can't be null!");    PRUnichar * docTitleStr;    PRUnichar * docURLStr;    GetWebShellTitleAndURL(po->mWebShell, &docTitleStr, &docURLStr);    // Use the URL if the doc is empty    if (!docTitleStr || !*docTitleStr) {      if (docURLStr && nsCRT::strlen(docURLStr) > 0) {        nsMemory::Free(docTitleStr);        docTitleStr = docURLStr;      } else {        nsMemory::Free(docURLStr);      }      docURLStr = nsnull;      if (!docTitleStr || !*docTitleStr) {        CleanupDocTitleArray(array, i);        return NS_ERROR_OUT_OF_MEMORY;      }    }    array[i] = docTitleStr;    if (docURLStr) nsMemory::Free(docURLStr);  }  *aCount  = numDocs;  *aResult = array;  return NS_OK;}