if (doc == nsnull) return NS_ERROR_OUT_OF_MEMORY; return doc->QueryInterface(NS_GET_IID(nsIDocument), (void**) aInstancePtrResult);
NS_ENSURE_TRUE(doc, NS_ERROR_OUT_OF_MEMORY);  nsresult rv = doc->Init();  if (NS_FAILED(rv)) { delete doc;  return rv; }  *aInstancePtrResult = doc; NS_ADDREF(*aInstancePtrResult);  return NS_OK;
NS_NewXMLDocument(nsIDocument** aInstancePtrResult){  nsXMLDocument* doc = new nsXMLDocument();  if (doc == nsnull)    return NS_ERROR_OUT_OF_MEMORY;  return doc->QueryInterface(NS_GET_IID(nsIDocument), (void**) aInstancePtrResult);}