NS_IF_RELEASE(gNameSpaceManager);  NS_IF_RELEASE(kClassAtom); NS_IF_RELEASE(kIdAtom);
XULContentSinkImpl::~XULContentSinkImpl(){    NS_IF_RELEASE(mParser); // XXX should've been released by now, unless error.    {        // There shouldn't be any here except in an error condition        PRInt32 i = mNameSpaceStack.Count();        while (0 < i--) {            nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack[i];#ifdef PR_LOGGING            if (PR_LOG_TEST(gLog, PR_LOG_ALWAYS)) {                nsAutoString uri;                nsCOMPtr<nsIAtom> prefixAtom;                nameSpace->GetNameSpaceURI(uri);                nameSpace->GetNameSpacePrefix(*getter_AddRefs(prefixAtom));                nsAutoString prefix;                if (prefixAtom)                    {                        const PRUnichar *unicodeString;                        prefixAtom->GetUnicode(&unicodeString);                        prefix = unicodeString;                    }                else                    {                        prefix.Assign(NS_LITERAL_STRING("<default>"));                    }                char* prefixStr = ToNewCString(prefix);                char* uriStr = ToNewCString(uri);                PR_LOG(gLog, PR_LOG_ALWAYS,                       ("xul: warning: unclosed namespace '%s' (%s)",                        prefixStr, uriStr));                nsCRT::free(prefixStr);                nsCRT::free(uriStr);            }#endif            NS_RELEASE(nameSpace);        }    }    // Pop all of the elements off of the context stack, and delete    // any remaining content elements. The context stack _should_ be    // empty, unless something has gone wrong.    while (mContextStack.Depth()) {        nsresult rv;        nsVoidArray* children;        rv = mContextStack.GetTopChildren(&children);        if (NS_SUCCEEDED(rv)) {            for (PRInt32 i = children->Count() - 1; i >= 0; --i) {                nsXULPrototypeNode* child =                    NS_REINTERPRET_CAST(nsXULPrototypeNode*, children->ElementAt(i));                delete child;            }        }        nsXULPrototypeNode* node;        rv = mContextStack.GetTopNode(&node);        if (NS_SUCCEEDED(rv)) delete node;        State state;        mContextStack.Pop(&state);    }    PR_FREEIF(mText);    if (--gRefCnt == 0) {        NS_IF_RELEASE(gNameSpaceManager);        NS_IF_RELEASE(kClassAtom);        NS_IF_RELEASE(kIdAtom);        NS_IF_RELEASE(kScriptAtom);        NS_IF_RELEASE(kStyleAtom);        NS_IF_RELEASE(kTemplateAtom);        if (gXULCache) {            nsServiceManager::ReleaseService(kXULPrototypeCacheCID, gXULCache);            gXULCache = nsnull;        }    }}