else if (mClassID.Equals(kAddressBookDB)) { nsresult rv; nsAddrDatabase * abDatabase = new nsAddrDatabase(); if (abDatabase) rv = abDatabase->QueryInterface(aIID, aResult); else rv = NS_ERROR_OUT_OF_MEMORY;  if (NS_FAILED(rv) && abDatabase) delete abDatabase; return rv; }
nsresult nsAbFactory::CreateInstance(nsISupports *aOuter, const nsIID &aIID, void **aResult)  {  	if (aResult == NULL)  		return NS_ERROR_NULL_POINTER;  	*aResult = NULL;      	// ClassID check happens here	// Whenever you add a new class that supports an interface, plug it in here!!!		if (mClassID.Equals(kAbDirectoryDataSourceCID)) 	{		nsresult rv;		nsABDirectoryDataSource * directoryDataSource = new nsABDirectoryDataSource();		if (directoryDataSource)			rv = directoryDataSource->QueryInterface(aIID, aResult);		else			rv = NS_ERROR_OUT_OF_MEMORY;		if (NS_FAILED(rv) && directoryDataSource)			delete directoryDataSource;		return rv;	}	else if (mClassID.Equals(kAbDirectoryCID)) 	{		nsresult rv;		nsABDirectory * directory = new nsABDirectory();		if (directory)			rv = directory->QueryInterface(aIID, aResult);		else			rv = NS_ERROR_OUT_OF_MEMORY;		if (NS_FAILED(rv) && directory)			delete directory;		return rv;	}	if (mClassID.Equals(kAbCardDataSourceCID)) 	{		nsresult rv;		nsABCardDataSource * cardDataSource = new nsABCardDataSource();		if (cardDataSource)			rv = cardDataSource->QueryInterface(aIID, aResult);		else			rv = NS_ERROR_OUT_OF_MEMORY;		if (NS_FAILED(rv) && cardDataSource)			delete cardDataSource;		return rv;	}	else if (mClassID.Equals(kAbCardCID)) 	{		nsresult rv;		nsABCard * card = new nsABCard();		if (card)			rv = card->QueryInterface(aIID, aResult);		else			rv = NS_ERROR_OUT_OF_MEMORY;		if (NS_FAILED(rv) && card)			delete card;		return rv;	}	return NS_NOINTERFACE;  }  