if (head->mContent == aContent) { NS_ERROR("attempt to add same element twice"); return NS_ERROR_ILLEGAL_VALUE;
if (head->mContent.get() == aContent) {        #ifdef PR_LOGGING if (PR_LOG_TEST(gMapLog, PR_LOG_ALWAYS)) { nsresult rv;  nsCOMPtr<nsIAtom> tag; rv = aContent->GetTag(getter_AddRefs(tag)); if (NS_FAILED(rv)) return rv;  nsAutoString tagname; rv = tag->ToString(tagname); if (NS_FAILED(rv)) return rv;  nsCAutoString tagnameC, aidC; tagnameC.AssignWithConversion(tagname); aidC.AssignWithConversion(id, aID.Length()); PR_LOG(gMapLog, PR_LOG_ALWAYS, ("xulelemap(%p) dup    %s[%p] <-- %s\n", this, tagnameC.get(), aContent, aidC.get())); } #endif  return NS_OK;
nsElementMap::Add(nsIRDFResource* aResource, nsIContent* aContent){    NS_PRECONDITION(mResources != nsnull, "not initialized");    if (! mResources)        return NS_ERROR_NOT_INITIALIZED;    ContentListItem* head =        (ContentListItem*) PL_HashTableLookup(mResources, aResource);    if (! head) {        head = new ContentListItem(aContent);        if (! head)            return NS_ERROR_OUT_OF_MEMORY;        PL_HashTableAdd(mResources, aResource, head);        NS_ADDREF(aResource);        NS_ADDREF(aContent);    }    else {        while (1) {            if (head->mContent == aContent) {                NS_ERROR("attempt to add same element twice");                return NS_ERROR_ILLEGAL_VALUE;            }            if (! head->mNext)                break;            head = head->mNext;        }        head->mNext = new ContentListItem(aContent);        if (! head->mNext)            return NS_ERROR_OUT_OF_MEMORY;        NS_ADDREF(aContent);    }    return NS_OK;}