NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
NS_GetContentList(nsIDocument* aDocument, nsIAtom* aMatchAtom,                  PRInt32 aMatchNameSpaceId, nsIContent* aRootContent,                  nsIContentList** aInstancePtrResult){  *aInstancePtrResult = nsnull;  nsContentList* list = nsnull;  static PLDHashTableOps hash_table_ops =  {    PL_DHashAllocTable,    PL_DHashFreeTable,    ContentListHashtableGetKey,    ContentListHashtableHashKey,    ContentListHashtableMatchEntry,    PL_DHashMoveEntryStub,    PL_DHashClearEntryStub,    PL_DHashFinalizeStub  };  // Initialize the hashtable if needed.  if (!gContentListHashTable.ops) {    PRBool success = PL_DHashTableInit(&gContentListHashTable,                                       &hash_table_ops, nsnull,                                       sizeof(ContentListHashEntry),                                       16);    if (!success) {      gContentListHashTable.ops = nsnull;    }  }    ContentListHashEntry *entry = nsnull;  // First we look in our hashtable.  Then we create a content list if needed  if (gContentListHashTable.ops) {    nsContentListKey hashKey(aDocument, aMatchAtom,                             aMatchNameSpaceId, aRootContent);        // A PL_DHASH_ADD is equivalent to a PL_DHASH_LOOKUP for cases    // when the entry is already in the hashtable.    entry = NS_STATIC_CAST(ContentListHashEntry *,                           PL_DHashTableOperate(&gContentListHashTable,                                                &hashKey,                                                PL_DHASH_ADD));    if (entry)      list = entry->mContentList;  }  if (!list) {    // We need to create a ContentList and add it to our new entry, if    // we have an entry    list = new nsContentList(aDocument, aMatchAtom,                             aMatchNameSpaceId, aRootContent);    if (entry) {      if (list)        entry->mContentList = list;      else        PL_DHashTableRawRemove(&gContentListHashTable, entry);    }  }  NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);  *aInstancePtrResult = list;  NS_ADDREF(*aInstancePtrResult);  // Hold on to the last requested content list to avoid having it be  // removed from the cache immediately when it's released. Avoid  // bumping the refcount on the list if the requested list is the one  // that's already cached.  if (gCachedContentList != list) {    NS_IF_RELEASE(gCachedContentList);    gCachedContentList = list;    NS_ADDREF(gCachedContentList);  }  return NS_OK;}