nsAutoString args(aStatusArg);
const nsAutoString args(aStatusArg);
nsStringBundleService::FormatStatusMessage(nsresult aStatus,                                           const PRUnichar* aStatusArg,                                           PRUnichar* *result){  nsresult rv;  PRUint32 i, argCount = 0;  nsCOMPtr<nsIStringBundle> bundle;  nsXPIDLCString stringBundleURL;  // XXX hack for mailnews who has already formatted their messages:  if (aStatus == NS_OK && aStatusArg) {    *result = nsCRT::strdup(aStatusArg);    return NS_OK;  }  if (aStatus == NS_OK) {    return NS_ERROR_FAILURE;       // no message to format  }  // format the arguments:  nsAutoString args(aStatusArg);  argCount = args.CountChar(PRUnichar('\n')) + 1;  NS_ENSURE_ARG(argCount <= 10); // enforce 10-parameter limit  PRUnichar* argArray[10];  // convert the aStatusArg into a PRUnichar array  if (argCount == 1) {    // avoid construction for the simple case:    argArray[0] = (PRUnichar*)aStatusArg;  }  else if (argCount > 1) {    PRInt32 offset = 0;    for (i = 0; i < argCount; i++) {      PRInt32 pos = args.FindChar('\n', PR_FALSE, offset);      if (pos == -1)         pos = args.Length();      nsAutoString arg;      args.Mid(arg, offset, pos);      argArray[i] = ToNewUnicode(arg);      if (argArray[i] == nsnull) {        rv = NS_ERROR_OUT_OF_MEMORY;        argCount = i - 1; // don't try to free uninitialized memory        goto done;      }      offset = pos + 1;    }  }  // find the string bundle for the error's module:  rv = mErrorService->GetErrorStringBundle(NS_ERROR_GET_MODULE(aStatus),                                            getter_Copies(stringBundleURL));  if (NS_SUCCEEDED(rv)) {    rv = getStringBundle(stringBundleURL, mAsync?PR_TRUE:PR_FALSE, getter_AddRefs(bundle));    if (NS_SUCCEEDED(rv)) {      rv = FormatWithBundle(bundle, aStatus, argCount, argArray, result);    }  }  if (NS_FAILED(rv)) {    rv = getStringBundle(GLOBAL_PROPERTIES, mAsync?PR_TRUE:PR_FALSE, getter_AddRefs(bundle));    if (NS_SUCCEEDED(rv)) {      rv = FormatWithBundle(bundle, aStatus, argCount, argArray, result);    }  }done:  if (argCount > 1) {    for (i = 0; i < argCount; i++) {      if (argArray[i])        nsMemory::Free(argArray[i]);    }  }  return rv;}